MySQL BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY

128 views
Skip to first unread message

Ori S

unread,
Oct 24, 2015, 4:18:27 PM10/24/15
to ORMLite Developers
Hi all.

I hope the subject says it all: How to emulate this PRIMARY KEY in ORMLite?
I tried to use BigInteger and enforce the DataType to LONG, but somewhere in the code, ORMLite screams about "This field cannot have that type" or something similar...

Anyway, anybody managed to emulate this in ORMLite?

Thanks.

/OS

Ori S

unread,
Mar 13, 2016, 12:36:28 PM3/13/16
to ORMLite Developers
*bump*

Gray Watson

unread,
Mar 13, 2016, 5:21:18 PM3/13/16
to ORMLite Developers
The problem I have with this is that the BigInteger stores a value greater than a LONG in many data-types. That's why it is supposed to be a String output. See:

https://github.com/j256/ormlite-core/blob/master/src/main/java/com/j256/ormlite/field/types/BigIntegerType.java

It seems strange to me to make this an ID type since a long is quite adequate, especially if it is becoming a LONG at the database. That said, you could override the BigIntegerType and make a BigIntegerIdType that extends BigIntegerType and returns true from isAppropriateId() and then use the DatabaseField.persisterClass to set it.

gray
> --
> You received this message because you are subscribed to the Google Groups "ORMLite Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ormlite-dev...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Ori S

unread,
Mar 27, 2016, 2:44:45 PM3/27/16
to ORMLite Developers
Thanks a lot, Gary, for the response.

Would you consider merging this code change into the source code if I push a request?

/OS
Reply all
Reply to author
Forward
0 new messages