-->
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: Oracle sequence value - remove SELECT sequence.NEXTVAL
PostPosted: Fri Jun 10, 2016 5:13 am 
Newbie

Joined: Fri Jun 10, 2016 4:41 am
Posts: 1
Hello,
Is there an option to remove "SELECT sequence.NEXTVAL FROM dual" everytime we need a value from an Oracle sequence?
I thought something like "insert into test (id,b,c) values (test_seq.nextval,:1,:2)".
Thank you,
Radovan


Top
 Profile  
 
 Post subject: Re: Oracle sequence value - remove SELECT sequence.NEXTVAL
PostPosted: Fri Jun 10, 2016 6:08 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
The id must be generated prior to the insert statement because of the write-behind transactional cache. Behind the scenes, Hibernate uses a Map-like structure to cache all managed entities in what's commonly called the 1st-level cache. The cache key is formed of the Entity class and the Entity identifier, hence the identifier must be known when the entity becomes managed.

Also worth mentioning that when you persist an entity, the insert statement is not generated right away. The insert statement is delayed until a flush occurs.

If you want to optimize the number of sequence calls, you should use the pooled optimizer.


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.