hibernatejpa

Unsigned Int in JPA and Hibernate


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


Solution

  • 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.