In most databases a BIGINT is a 64bit integer. Does anyone know why Hibernate maps these to BigInteger instead of Long? I can handle these well but I'm just curious.
You can see their default mapping for this type in Dialect.java. I even found a hibernate issue but there are no comments indicating why this would be the case.
https://hibernate.atlassian.net/browse/HHH-7318
I assume there must be a reason for this choice but I haven't had any success with google.
Also, what would be the impact of subclassing my databases dialect and overriding this?
Thanks!
Quite probably because BIGINT
s can be unsigned (in MySQL at least, if not in other RDBMSs).
The only Java type that can hold the full range of a 64-bit unsigned integer is BigInteger
. It would be incorrect to use a long
for this, as this would convert 18446744073709551615 (264 - 1) to -1.
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