JPA和Hibernate中的未签名Int [英] Unsigned Int in JPA and Hibernate
本文介绍了JPA和Hibernate中的未签名Int的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我能做些什么JPA(我使用Hibernate)创建带有无符号类型的列?目前我所有的ID列都已经过签名。
解决方案
使用 columnDefinition
@Column
注解应该这样做。对于您要使用的SQL类型进行总计猜测:
private long foo;
@Column(columnDefinition =UNSIGNED INT(11))
public long getFoo()
{
return foo;
code
NB 不是所有的数据库(如SQL Server,我认为)支持unsigned int类型。
What can i do so JPA (i use Hibernate) creates Columns with Unsigned types? Currently all my ID columns are signed.
解决方案 Using the columnDefinition
property on the @Column
annotation should do it. Taking a total guess at the SQL type you're going for:
private long foo;
@Column(columnDefinition = "UNSIGNED INT(11)")
public long getFoo()
{
return foo;
}
N.B. Not all databases (like SQL Server, I think) support unsigned int types.
这篇关于JPA和Hibernate中的未签名Int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文