In our working project,as part of upgrade from hibernate 3 to hibernate 5, I am getting error "SQLSyntaxErrorException: Unknown column <columnName> in field list". Digging more into the issue found table annotation is not taking into account the schema name. Tried a standalone test case to confirm the issue. Here i am not getting error but i am getting empty list. Whatever schema name i give, i am getting same result. List<Cluster> clustersList = session.createCriteria(Cluster.class).list();
Had discussion in hibernate forum https://discourse.hibernate.org/t/sqlsyntaxerrorexception-unknown-column-columnname-in-field-list/1448
Hibernate version used: 5.1.15
@ Table(name = "cluster", schema = "schema1") @ SecondaryTable(name = "Cluster", schema = "schema2", pkJoinColumns = @PrimaryKeyJoinColumn(name = "clusterId", referencedColumnName = "objid")) @ org.hibernate.annotations.Table(appliesTo = "Cluster", optional = false) @ Entity @ OptimisticLocking(type = OptimisticLockType.DIRTY) @ DynamicUpdate public class Cluster implements Serializable {
Tried a standalone test case to confirm the issue (getting empty list). hhh123Test test in org.hibernate.bugs.ORMUnitTestCase class is using criteria to fetch values. Attached image of table and debug of query generated will provide more detail. |
|