We're using @TableGenerator as our ID generation mechanism, but we're seeing some odd results on a handful of our entities. The "value" of the stored id is being multiplied by a factor of 100 before being used as an ID.
This results in a id "value" of 4002 being persisted as 400200.
Our generator annotation:
Code:
@TableGenerator(
name = "paymentIdGenerator",
table = "hibernate_seqs",
pkColumnName = "name",
valueColumnName = "next_id",
pkColumnValue = "payment",
allocationSize = 100)
And the corresponding entry in the sequence table:
Code:
mysql> select * from hibernate_seqs where name = 'payment';
+---------+---------+
| name | next_id |
+---------+---------+
| payment | 4002 |
+---------+---------+
I'm at a total loss to explain it... My understanding is that the generator would allocate a batch of ID's through a local mechanism and increment the ID values of persisted entities using the batched IDs. This is obviously not happening as 4002 != 400200.
Anyone know why this is happening? Is there some undocumented internals of the TableGenerator scheme that might account for this?
Unfortunately moving to a separate generator scheme isn't an option either. The application needs to be able to operate on several different databases (db is the customers choice), so we must stay database agnostic and the @TableGenerator is the only way to reliably do this.
Thanks,
-Brian