What can i do so JPA (i use Hibernate) creates Columns with Unsigned types? Currently all my ID columns are signed.
You cant actually use both of them in the same application. For backwards compatibility. We are expanding our application and want to start using Spring Data JPA, but still keep the old hibernate implementation. Its better you develop your new application as a separate microservice and use spring data jpa ..
If your object does not have an id, but its table does, this is fine. Make the object an Embeddable object, embeddable objects do not have ids. You will need a Entity that contains this Embeddable to persist and query it. Save this answer.
Let's start with the @Column annotation. It is an optional annotation that enables you to customize the mapping between the entity attribute and the database column.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With