I don't think my problem is database related.  

Arno, did you see if the next value of your postgres sequence corresponded to 
the value actually inserted?

I launched jboss in debug mode and attached eclipse remotely to it and found 
the hibernate class which is applying modifications to the value returned from 
the database sequence.

The generated id is being generated by org.hibernate.id.SequenceHiLoGenerator.  
Here is the method.

        public synchronized Serializable generate(SessionImplementor session, 
Object obj) 
  |     throws HibernateException {
  |             if (maxLo < 1) {
  |                     //keep the behavior consistent even for boundary usages
  |                     long val = ( (Number) super.generate(session, obj) 
).longValue();
  |                     if (val == 0) val = ( (Number) super.generate(session, 
obj) ).longValue();
  |                     return IdentifierGeneratorFactory.createNumber( val, 
returnClass );
  |             }
  |             if ( lo>maxLo ) {
  |                     long hival = ( (Number) super.generate(session, obj) 
).longValue();
  |                     lo = (hival == 0) ? 1 : 0;
  |                     hi = hival * ( maxLo+1 );
  |                     if ( log.isDebugEnabled() )
  |                             log.debug("new hi value: " + hival);
  |             }
  | 
  |             return IdentifierGeneratorFactory.createNumber( hi + lo++, 
returnClass );
  |     }


I would like to have the id, generated by org.hibernate.id.SequenceGenerator 
instead of org.hibernate.id.SequenceHiLoGenerator.   Is there a way to specify 
the class which should be used as the generator?

I read some of the comments for both of these generators and it looks like the 
HiLo version is used for performance. I believe it is able to reserve chunks of 
sequence numbers at a time.  But I was trying to created entity beans for an 
existing database and still fit the same sequence/id usage pattern of the old 
code.


View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3961349#3961349

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3961349
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to