<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Query by joining two tables from different scope</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=120643063" />
  <subtitle>Query by joining two tables from different scope</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=120643063</id>
  <updated>2026-04-26T12:36:12Z</updated>
  <dc:date>2026-04-26T12:36:12Z</dc:date>
  <entry>
    <title>RE: Query by joining two tables from different scope</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120657154" />
    <author>
      <name>Andrew Jardine</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120657154</id>
    <updated>2021-03-02T13:18:19Z</updated>
    <published>2021-03-02T13:18:03Z</published>
    <summary type="html">&lt;p&gt;.. The only thing I would add here is that the dummy entities got a
  little bit cleaner in 7.2 because you can now generate service builder
  entities without the persistence layer. So that means you don't have
  to worry about &amp;quot;disabling&amp;quot; the crud operations. All you have
  to do is make sure that you set the
  attribute &lt;strong&gt;persistence=&amp;quot;false&amp;quot;&lt;/strong&gt; on the
  &amp;lt;entity/&amp;gt; definition and Service Builder will do the rest .. or
  rather do LESS for you :)&lt;/p&gt;</summary>
    <dc:creator>Andrew Jardine</dc:creator>
    <dc:date>2021-03-02T13:18:03Z</dc:date>
  </entry>
  <entry>
    <title>RE: Query by joining two tables from different scope</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120648338" />
    <author>
      <name>Christoph Rabel</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120648338</id>
    <updated>2021-02-25T18:21:19Z</updated>
    <published>2021-02-25T18:21:19Z</published>
    <summary type="html">&lt;p&gt;Here's the documentation for custom sql. I hope, it helps.&lt;/p&gt;
&lt;p&gt;https://help.liferay.com/hc/en-us/articles/360017882012-Custom-SQL&lt;/p&gt;
&lt;p&gt;When you write the code, you can add an Impl class that matches the
  table, in that example EntryImpl is used.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;q.addEntity(&amp;quot;GB_Entry&amp;quot;, EntryImpl.class);&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What I did before is was to add my own class that matched the result.
  I used the &amp;quot;dummy entity trick&amp;quot; by Dave Nebinger. It should
  still work.&lt;/p&gt;
&lt;p&gt;https://liferay.dev/blogs/-/blogs/fake-servicebuilder-entities&lt;br /&gt;
  &lt;br /&gt;But I think, doing that isn't strictly necessary, I think, any
  class works, as long as the column names match the setters/getters.
  But I could be wrong here.&lt;/p&gt;</summary>
    <dc:creator>Christoph Rabel</dc:creator>
    <dc:date>2021-02-25T18:21:19Z</dc:date>
  </entry>
  <entry>
    <title>Query by joining two tables from different scope</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120643062" />
    <author>
      <name>Ronak Parekh</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120643062</id>
    <updated>2021-02-23T12:46:50Z</updated>
    <published>2021-02-23T12:46:50Z</published>
    <summary type="html">&lt;p&gt;Hello Team,&lt;/p&gt;
&lt;p&gt;I want to query by joining two tables: one is portal level entity and
  another one is custom entity i.e JournalArticle and ArticleUserMapping
  entity. Please suggest how can I query by joining these two tables. I
  have tried using Dynamic Query but in Liferay 7.2 I am not able to
  create dynamic query with alias and I think without alias I won't able
  to query as per my requirement.&lt;/p&gt;
&lt;p&gt;How can I use custom sql? How can I write custom sql of journal
  article entity joined with custom entity in custom entity's finder impl&lt;/p&gt;
&lt;p&gt;Kindly help.&lt;/p&gt;
&lt;p&gt;Thank you. &lt;/p&gt;</summary>
    <dc:creator>Ronak Parekh</dc:creator>
    <dc:date>2021-02-23T12:46:50Z</dc:date>
  </entry>
</feed>
