BIT(1)HIPA联合JPA映射

问题描述 投票:1回答:1

在Postgresql中,我有一列的类型为BIT(1)。在JPA映射中,就像:

@Column(columnDefinition="bit(1)")
private String type;

但是,当我执行测试时,会发生此错误:

错误:“类型”列的类型为bit,但表达式的类型为字符变化提示:您将需要重写或强制转换表达式。排名:117

我尝试过其他Java类型:char,int,Boolean和BitSet。但是,会发生相同的错误。

您知道如何将Postgresql类型BIT(1)映射到Hibernate JPA吗?

java jpa jdbc types hibernate-mapping
1个回答
0
投票

Postgress不支持类型位。尝试在转换中使用spring JPA的本地查询。例如:

@Modifying  @Query(value = "update table set is_active = cast(:is_activeas bit) where id = :id", nativeQuery = true)

int updateTable(@Param("is_active") int isActive, @Param("id") long id);
© www.soinside.com 2019 - 2024. All rights reserved.