Unsigned Int in JPA and Hibernate

后端 未结 1 725
别那么骄傲
别那么骄傲 2021-01-12 00:58

What can i do so JPA (i use Hibernate) creates Columns with Unsigned types? Currently all my ID columns are signed.

1条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-12 01:12

    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.

    0 讨论(0)
提交回复
热议问题