I have a simple class with an id property that I would like to be created as a bigint.
Here is the property
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@NotNull
public java.math.BigInteger id;
However this is generates this:
id decimal(19,2) not null auto_increment
I can of course add
@Column(columnDefinition = "bigint(20)")
And then it works but I can't undarstand why dose JPA prefer to match to decimal instead of bigint.
The generated mapping also causes an error for an invalid id because the decimal is not auto_incrementable.
I'm using spring boot with spring-boot-starter-data-jpa dependancy. The configurations is as follows:
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=create
Any ideas?
The JDBC type BIGINT represents a 64-bit signed integer value between -9223372036854775808 and 9223372036854775807. The corresponding SQL type BIGINT is a non-standard extension to SQL. In practice the SQL BIGINT type is not yet currently implemented by any of the major databases, and we recommend that its use should be avoided in portable code.
The recommended Java mapping for the BIGINT type is as a Java long.
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