CustomSQLUtil gets null during query search using Liferay 7

While I had no problems with the CustomSQLUtil class in Liferay 6.2, I encounter a problem with the new version of this class in Liferay 7. Indeed, the get method returns null instead of the expected query.

Has anyone reproduced this?

Here is a description of my latest Eclipse Mars test:

  • In my Liferay workspace, I added the following line to the build.gradle of the service module

compileOnly group: "com.liferay", name: "com.liferay.portal.dao.orm.custom.sql", version: "1.0.5"

  1. After updating gradle, I can use the CustomSQLUtil class in my FooFinderImpl class to get the corresponding query.

  2. This query was written in the default.xml file, which is uploaded to the src / custom-sql folder, as indicated in the Liferay 7 documentation:

https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/custom-sql

I tried with many places (in META-INF, in ressources ..), I even tried to expand my own CustomSQL class to get the configuration, but the getSQL method of the CustomSQLUtil class always returns null sql queries.

PS: I noticed that this new method "CustomSQLUtil.get" now takes 2 parameters, the class is requested in addition to the request identifier. In this class parameter, I put the value "Foo.class".

Does anyone know if there is a configuration? Should the pathpath or bundlecontext class be configured?

+4
2

, custom-sql/default.xml foo-service/src/main/resources, FooFinderImpl CustomSQLUtil

CustomSQLUtil.get(getClass(),CONSTANT_QUERY_ID); //id of query in default.xml

github https://github.com/bruinen/liferay-services-example

+5

CustomSQLUtil. ,          String sql = "select * from Foo_Foo name=?" , !

0

Source: https://habr.com/ru/post/1663066/


All Articles