[jboss-user] [EJB3] - JPA Sequence generated value is different from Oracle sequence nextVal

Aslam Khatri do-not-reply at jboss.com
Tue May 8 05:31:43 EDT 2012


Aslam Khatri [https://community.jboss.org/people/aslamk] created the discussion

"JPA Sequence generated value is different from Oracle sequence nextVal"

To view the discussion, visit: https://community.jboss.org/message/734231#734231

--------------------------------------------------------------
The default sequence generator of JPA (SequenceHiloGenerator with allocationSize=50 ) generates a sequence value which is different from the corresponding oracle sequence's nextVal. 

We have used  allocationSize=50 for performance improvement but this creates problem by generating values which are not matching with the corresponding sequence values. In my case if nextVal of the sequence is 250 then the value generated by the JPA is far more than 250. I want the generator behaviour to return database sequence values while giving me performance enhancement by calling database sequence only once for every 50 inserts.  

I know setting allocationSize=1 would generate value same as database sequence nextVal but in this case it makes select query for each insert to the table. I want to get rid of the selects for the inserts and thats why I moved on approach for HiliGenerator using allocationSize=50 but in this case facing problem of generated value not having in sync with the database sequence.

I would appreciate if anyone suggest a solution for this problem. 

Regards
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/734231#734231]

Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120508/c81ccf8e/attachment.html 


More information about the jboss-user mailing list