I am using Spring boot 3.1.3 with Hibernate 6.2.8.Final now which i migrated from Spring book 3.0.7 and hibernate 6.1.7.Final
I have the following class
@Entity
@Table(name = "product")
public class Product {
.....
@Column
protected Boolean deleted;
....
}
with the following spring JPA repository query :
public interface ProductDao extends CrudRepository<Long,Product > {
@Query("select m.version from Product m where m.entityId = :entityId and m.endDatetime = null and m.deleted <> 1")
Long findVersionByEntityIdAndEndDatetimeIsNull(@Param("entityId") Long entityId);
}
When i start the app i get the following error
Caused by: org.hibernate.query.sqm.InterpretationException: Error interpreting query [select m.version from Product m where m.entityId = :entityId and m.endDatetime = null and m.deleted <> 1]; this may indicate a semantic (user query) problem or a bug in the parser [select m.version from Product m where m.entityId = :entityId and m.endDatetime = null and m.deleted <> 1]
at org.hibernate.query.hql.internal.StandardHqlTranslator.translate(StandardHqlTranslator.java:97) ~[hibernate-core-6.2.8.Final.jar:6.2.8.Final]
at org.hibernate.query.internal.QueryInterpretationCacheStandardImpl.createHqlInterpretation(QueryInterpretationCacheStandardImpl.java:165) ~[hibernate-core-6.2.8.Final.jar:6.2.8.Final]
at org.hibernate.query.internal.QueryInterpretationCacheStandardImpl.resolveHqlInterpretation(QueryInterpretationCacheStandardImpl.java:147) ~[hibernate-core-6.2.8.Final.jar:6.2.8.Final]
at org.hibernate.internal.AbstractSharedSessionContract.interpretHql(AbstractSharedSessionContract.java:741) ~[hibernate-core-6.2.8.Final.jar:6.2.8.Final]
at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:786) ~[hibernate-core-6.2.8.Final.jar:6.2.8.Final]
… 161 common frames omitted
Caused by: java.lang.IllegalArgumentException: Can’t compare test expression of type [BasicSqmPathSource(deleted : Boolean)] with element of type [basicType@6(java.lang.Integer,4)]
at org.hibernate.query.sqm.internal.SqmCriteriaNodeBuilder.assertComparable(SqmCriteriaNodeBuilder.java:2102) ~[hibernate-core-6.2.8.Final.jar:6.2.8.Final]
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitComparisonPredicate(SemanticQueryBuilder.java:2493) ~[hibernate-core-6.2.8.Final.jar:6.2.8.Final]
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitComparisonPredicate(SemanticQueryBuilder.java:253) ~[hibernate-core-6.2.8.Final.jar:6.2.8.Final]
at org.hibernate.grammars.hql.HqlParser$ComparisonPredicateContext.accept(HqlParser.java:6111) ~[hibernate-core-6.2.8.Final.jar:6.2.8.Final]
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitAndPredicate(SemanticQueryBuilder.java:2314) ~[hibernate-core-6.2.8.Final.jar:6.2.8.Final]
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitAndPredicate(SemanticQueryBuilder.java:253) ~[hibernate-core-6.2.8.Final.jar:6.2.8.Final]
at org.hibernate.grammars.hql.HqlParser$AndPredicateContext.accept(HqlParser.java:6013) ~[hibernate-core-6.2.8.Final.jar:6.2.8.Final]
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitWhereClause(SemanticQueryBuilder.java:2297) ~[hibernate-core-6.2.8.Final.jar:6.2.8.Final]
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitWhereClause(SemanticQueryBuilder.java:253) ~[hibernate-core-6.2.8.Final.jar:6.2.8.Final]
at org.hibernate.grammars.hql.HqlParser$WhereClauseContext.accept(HqlParser.java:5910) ~[hibernate-core-6.2.8.Final.jar:6.2.8.Final]
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitQuery(SemanticQueryBuilder.java:1161) ~[hibernate-core-6.2.8.Final.jar:6.2.8.Final]
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitQuerySpecExpression(SemanticQueryBuilder.java:937) ~[hibernate-core-6.2.8.Final.jar:6.2.8.Final]
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitQuerySpecExpression(SemanticQueryBuilder.java:253) ~[hibernate-core-6.2.8.Final.jar:6.2.8.Final]
at org.hibernate.grammars.hql.HqlParser$QuerySpecExpressionContext.accept(HqlParser.java:1818) ~[hibernate-core-6.2.8.Final.jar:6.2.8.Final]
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitSimpleQueryGroup(SemanticQueryBuilder.java:931) ~[hibernate-core-6.2.8.Final.jar:6.2.8.Final]
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitSimpleQueryGroup(SemanticQueryBuilder.java:253) ~[hibernate-core-6.2.8.Final.jar:6.2.8.Final]
at org.hibernate.grammars.hql.HqlParser$SimpleQueryGroupContext.accept(HqlParser.java:1711) ~[hibernate-core-6.2.8.Final.jar:6.2.8.Final]
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitSelectStatement(SemanticQueryBuilder.java:418) ~[hibernate-core-6.2.8.Final.jar:6.2.8.Final]
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitStatement(SemanticQueryBuilder.java:377) ~[hibernate-core-6.2.8.Final.jar:6.2.8.Final]
at org.hibernate.query.hql.internal.SemanticQueryBuilder.buildSemanticModel(SemanticQueryBuilder.java:295) ~[hibernate-core-6.2.8.Final.jar:6.2.8.Final]
at org.hibernate.query.hql.internal.StandardHqlTranslator.translate(StandardHqlTranslator.java:81) ~[hibernate-core-6.2.8.Final.jar:6.2.8.Final]
… 165 common frames omitted