Friday, May 5, 2017

Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: myzc_string_record is not mapped

What

Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: myzc_string_record is not mapped
 at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:171) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
 at org.hibernate.hql.internal.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:91) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
 at org.hibernate.hql.internal.ast.tree.FromClause.addFromElement(FromClause.java:76) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
 at org.hibernate.hql.internal.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:321) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
 at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3687) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
 at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3576) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
 at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:716) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
 at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:572) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
 at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:309) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
 at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:257) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
 at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:262) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
 at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:190) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
 ... 58 common frames omitted


Why

Below is my old query sql. and i used it in spring boot jpa environment:
@Query(value = "select key_type,max(key_id) from myzc_string_record group by key_type")
 Map selectMaxKeyTypeAndId();

How
Below is my new query sql,add nativeQuery = true:
@Query(value = "select key_type,max(key_id) from myzc_string_record group by key_type", nativeQuery = true)
 Map selectMaxKeyTypeAndId();

Last
Thanks!

No comments: