Java org.hibernate.type.NumericBooleanType未转换JPASQLQuery中的值
在我的模型中,我声明此NumericBooleanType属性:Java org.hibernate.type.NumericBooleanType未转换JPASQLQuery中的值,java,spring-boot,hibernate,Java,Spring Boot,Hibernate,在我的模型中,我声明此NumericBooleanType属性: @Column(name = "ST_ATIVO", nullable = false) @Type(type = "org.hibernate.type.NumericBooleanType") private Boolean ativo; 然后,在antother类中,我尝试执行以下查询: List<Long> test = this.sqlQueryFactory.que
@Column(name = "ST_ATIVO", nullable = false)
@Type(type = "org.hibernate.type.NumericBooleanType")
private Boolean ativo;
然后,在antother类中,我尝试执行以下查询:
List<Long> test = this.sqlQueryFactory.query()
.select(equipe.id)
.from(equipe)
.where(equipe.ativo.isTrue())
.fetch();
hibernate不应该将查询中的NumericBooleanType布尔属性转换为int吗?不清楚您使用的是什么查询api。假设您使用,您可以尝试以下方式更正查询:
JPAQueryFactory queryFactory=新的JPAQueryFactory(entityManager);
列表测试=queryFactory.query()
.选择(设备id)
.来自(装备)
.式中(等效等式(真实))
.fetch();
能否显示ST|ATIVO
columntb|u table | ST|ATIVO | integer的ddl
org.hibernate.exception.SQLGrammarException: could not extract ResultSet
Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: integer = boolean