我有一个服务实体声明,如下所示:
<entity name="MyContentRepo" local-service="true" remote-service="true" table="contentrepo">
</entity>
我正在尝试使用自定义 SQL 来获取一些详细信息:
session = openSession();
String sqlQueryString = CustomSQLUtil.get("query_id");
SQLQuery query = session.createSQLQuery(sqlQueryString);
query.addEntity("MyContentRepo", MyContentRepoImpl.class);
QueryPos qPos = QueryPos.getInstance(query);
qPos.add("someparameter");
list = (List<MyContentRepo>) query.list();
但我在执行时收到以下错误:
08:02:26,640 ERROR [http-bio-8090-exec-72][JDBCExceptionReporter:82] Table 'mysqldb.mycontentrepo' doesn't exist
com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.exception.SQLGrammarException: could not execute query
查询使用声明的实体名称而不是 table="contentrepo"。谁能告诉我如何绕过这个问题?