MultipleHiLoPerTableGenerator can contain stale hi value, generate duplicate IDs
--------------------------------------------------------------------------------
Key: HHH-3507
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3507
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.0.SP1
Environment: Hibernate 3.3.0SP1 on MySQL 5.0.37-community-nt
Reporter: Christopher Wong
An instance of MultipleHiLoPerTableGenerator seems to be created per table (and per
schema?). This instance seems to persist across DB sessions/transactions, retaining the
"hi" value that it last loaded from the generator table. The problem comes when
the generator retains this "hi" value across a DB reset. It is not unusual to
reinitialize a schema for a new customer, or to restore a backup dump. The problem is that
when a DB is reset, this "hi" value is no longer valid, causing the IDs to wrap
around and eventually duplicate. Example sequence:
generate ID 195
generate ID 196
<DB reset.>
generate ID 197
generate ID 198
generate ID 199
<max lo reached. Load new "hi" value from DB.>
generate ID 1
generate ID 2
... (etc) ...
generate ID 196
generate ID 197 (ID is now duplicated, causing NonUniqueObjectException)
Perhaps the generator can recheck the generator table at the beginning of a transaction to
ensure its hi value is consistent.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira