<?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>DynamicQuery and Liferay 7.1 OSGI service modules</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=112821059" />
  <subtitle>DynamicQuery and Liferay 7.1 OSGI service modules</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=112821059</id>
  <updated>2026-04-05T00:21:04Z</updated>
  <dc:date>2026-04-05T00:21:04Z</dc:date>
  <entry>
    <title>RE: DynamicQuery and Liferay 7.1 OSGI service modules</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112836553" />
    <author>
      <name>David H Nebinger</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112836553</id>
    <updated>2019-03-20T13:12:59Z</updated>
    <published>2019-03-20T13:12:59Z</published>
    <summary type="html">You&amp;#39;re preaching to the choir, brother.</summary>
    <dc:creator>David H Nebinger</dc:creator>
    <dc:date>2019-03-20T13:12:59Z</dc:date>
  </entry>
  <entry>
    <title>RE: DynamicQuery and Liferay 7.1 OSGI service modules</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112833954" />
    <author>
      <name>Kevin Neibarger</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112833954</id>
    <updated>2019-03-20T11:48:56Z</updated>
    <published>2019-03-20T11:48:56Z</published>
    <summary type="html">Thanks! Great information, would be nice if this kind of information was in the documentation. Would be nice to see something like that in the JavaDoc. </summary>
    <dc:creator>Kevin Neibarger</dc:creator>
    <dc:date>2019-03-20T11:48:56Z</dc:date>
  </entry>
  <entry>
    <title>RE: DynamicQuery and Liferay 7.1 OSGI service modules</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112823796" />
    <author>
      <name>David H Nebinger</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112823796</id>
    <updated>2019-03-19T20:23:08Z</updated>
    <published>2019-03-19T20:23:08Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Try using the following:&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;​​​​​​​DynamicQuery dynamicQuery = myClassLocalService.dynamicQuery();&lt;/code&gt;&lt;/pre&gt;​​​​​​​The static utils should not be used and honestly the "this.getClassLoader()" thing is too dependent upon the context it is invoked in to ensure the right class loader gets used.&lt;br&gt;&lt;br&gt;The dynamicQuery() method, available on all Service Builder local services, returns a DQ object ready to deal with the queries against the model interface defined for the local service. It takes all of the guesswork out of the construction and eliminates the class loader context issues faced by code in different modules.&lt;br&gt;​​​​​​​&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>David H Nebinger</dc:creator>
    <dc:date>2019-03-19T20:23:08Z</dc:date>
  </entry>
  <entry>
    <title>DynamicQuery and Liferay 7.1 OSGI service modules</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112821058" />
    <author>
      <name>Kevin Neibarger</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112821058</id>
    <updated>2019-03-19T14:26:44Z</updated>
    <published>2019-03-19T14:26:44Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;With the new implementation of OSGI modules in the service layer for Liferay 7.1, is there a way to use the DynamicQuery API without creating a FinderImpl? In 6.2 I could just call the DynamicQuery API from the XxxLocalServiceImpl.java code​​​​​​​&lt;br&gt;&lt;pre&gt;&lt;code&gt;DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(MyClass.class, this.getClassLoader());

dynamicQuery.add(junction).addOrder(OrderFactoryUtil.desc("createDate"));

List&amp;lt;myclass&amp;gt; rosterReviews = this.dynamicQuery(dynamicQuery);&amp;lt;/myclass&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;In 7.1 the above code simply returns an empty List. Whereas a call to &lt;strong&gt;XxxLocalServiceUtil.&lt;/strong&gt;&lt;strong&gt;findByxXX()&lt;/strong&gt; returns the actual data. I would prefer not having to create a whole other class for DynamicQuery calls..&amp;nbsp;&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Kevin Neibarger</dc:creator>
    <dc:date>2019-03-19T14:26:44Z</dc:date>
  </entry>
</feed>
