在使用Liferay 7进行查询检索期间,CustomSQLUtil获取null值

Vin*_*ent 4 liferay java-ee liferay-service-builder liferay-7

虽然我对Liferay 6.2中的CustomSQLUtil类没有任何问题,但是我在Liferay 7中遇到了这个类的新版本的问题.的确,get方法返回null而不是预期的查询.

有人复制了吗?

以下是我在Eclipse Mars中的最后一次测试的描述:

  1. 在我的Liferay工作区中,我在服务模块的build.gradle中添加了以下行

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

  1. 在gradle刷新之后,我能够在我的FooFinderImpl类中使用CustomSQLUtil类来检索适当的查询.

  2. 此查询已写入default.xml文件,该文件被放入sray/custom-sql文件夹中,如Liferay 7文档中所述:

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

我已经尝试了很多地方(在META-INF,在ressources ..),我甚至尝试扩展CustomSQL本机类来获取配置,但CustomSQLUtil类的get方法返回总是null而不是sql查询.

PS:我注意到这个新的"CustomSQLUtil.get"方法现在需要2个参数,除了查询ID之外还要求一个类.在这个类参数中,我输入了"Foo.class"值.

有人知道是否有配置要做?是否必须配置classpath或bundlecontext?

Rom*_*shi 5

为了使它工作添加custom-sql/default.xmlfoo-service/src/main/resources 随后的FooFinderImpl 使用CustomSQLUtil这样

CustomSQLUtil.get(getClass(),CONSTANT_QUERY_ID); //id of query in default.xml
Run Code Online (Sandbox Code Playgroud)

这是github上的一个例子https://github.com/bruinen/liferay-services-example