Reputation: 5489
What can i do so JPA (i use Hibernate) creates Columns with Unsigned types? Currently all my ID columns are signed.
Upvotes: 11
Views: 16460
Reputation: 790
MySQL has excellent documentation addressing the same problem. Link
If you are creating tables using DDLs (manually or using DB migration tools) and only want to understand which Java data type best suits your MySQL Unsigned Int column, the answer is long
/Long
.
Upvotes: 0
Reputation: 359816
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.
Upvotes: 20