user477768
user477768

Reputation:

JPA primary key for MySQL

I have a table which has the primary key of type BIGINT UNSIGNED. Now, how can I model this key in JPA? If I use java.math.BigInteger, JPA will not accept it. If I use Long, then the type of JPA seems to be too small in comparison with the type of MySQL. What if the number of records exceeds Long.MAX_VALUE ?

Upvotes: 1

Views: 184

Answers (1)

duffymo
duffymo

Reputation: 308743

You should use Long and sleep at night. Look at the max value for a long. If your table ever comes close to that number I'd be surprised. I know we live in the era of Big Data, but your fears are overblown and unrealistic in the near term.

Upvotes: 2

Related Questions