-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: @TableGenerator incrementing table value x100
PostPosted: Thu Feb 25, 2010 6:20 pm 
Newbie

Joined: Thu Feb 25, 2010 6:08 pm
Posts: 1
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


Top
 Profile  
 
 Post subject: Re: @TableGenerator incrementing table value x100
PostPosted: Fri Feb 26, 2010 3:46 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
What is the sequence of id's if you do several new inserts on the same entity-class within the same transaction.
Is is something like:

400200
400300
400400
...

or

400200
400201
400203
...

?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.