У меня есть сущность с id, case_id, именем, адресом, созданным, столбцами create_by.
Я использую @namednativequery, @sqlresultsetmapping, @entity и @entityresult и получаю 4 столбца.
@EntityResult(entityClass = com.hhs.entity.CaseEvent.class,
fields = { @FieldResult(name = "id", column = "id"),
@FieldResult(name = "caseid", column = "case_id"),
@FieldResult(name = "created", column = "created"),
@FieldResult(name = "createdby", column = "created_by")
} ) } )
Но приложение не работает со следующей ошибкой.
2019-09-19 19:13:51.523 ERROR 15888 --- [nio-8080-exec-5] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; SQL [SELECT id, case_id, created, created_by FROM hhs.case_event]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query] with root cause
org.postgresql.util.PSQLException: The column name created_3_9_0_ was not
found in this ResultSet.
at org.postgresql.jdbc.PgResultSet.findColumn(PgResultSet.java:2593) ~ [postgresql-42.2.5.jar!/:42.2.5]
at org.postgresql.jdbc.PgResultSet.getString(PgResultSet.java:2467) ~[postgresql-42.2.5.jar!/:42.2.5]
at com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java) ~[HikariCP-3.2.0.jar!/:na]
at org.hibernate.type.descriptor.sql.VarcharTypeDescriptor$2.doExtract(VarcharTypeDescriptor.java:62) ~[hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:47) ~[hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:261) ~[hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:257) ~[hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:247) ~[hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:333) ~[hibernate-core-5.3