我有一個id屬性的簡單類,我想創建一個bigint。JPA BigInteger beeing映射到MySQL的小數?
這裏是財產
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@NotNull
public java.math.BigInteger id;
然而,這是產生這樣的:
id decimal(19,2) not null auto_increment
我當然可以添加
@Column(columnDefinition = "bigint(20)")
然後它的工作原理,但我不能undarstand爲什麼劑量JPA更喜歡匹配到十進制而不是bigint。
生成的映射也會導致無效ID錯誤,因爲小數點不是auto_incrementable。
我使用spring-boot-starter-data-jpa依賴的spring引導。 配置如下:
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=create
任何想法?
AUTO_INCREMENT僅適用於整數和浮點類型。請參閱MySQL手冊CREATE TABLE。 AUTO_INCREMENT不適用於DECIMAL – mhasan
是的,我知道這一點。問題更多的是爲什麼jpa映射BigInteger類型的小數? – JustmeVSI