-->
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.  [ 1 post ] 
Author Message
 Post subject: Changing the way Hibernate uses Seq.nextval while inserting.
PostPosted: Tue Mar 31, 2009 5:05 am 
Newbie

Joined: Thu Mar 15, 2007 7:43 am
Posts: 8
Hi All,

We have recently migrated to Oracle 11g. Oracle recommends against, using the select sequencename.nextval from dual , specially in the non cached environment.

Recommended way is to use the sequencename.nextval directly in insert statement.

Is there way to change this behavior so that Hibernate do not do select first and then insert but do both things in one statement.

for e.g.
insert into table_name (id, ...) values ( sequencename.nextval , ....)

Looking forward for help here.

Best Regards


Hibernate version:

3.2.6

Mapping documents:

@Table(name = "KUNDEN_HISTORY_CHANGE")
public class CustomerHistoryChange implements Serializable {

@Id
@SequenceGenerator(name = "chc_sequence", sequenceName = "KUNDEN_HISTORY_CHANGE_SEQ")
@GeneratedValue(generator = "chc_sequence")
@Column(name = "KHC_ID")
private Long id;

Name and version of the database you are using:

Oracle 11 g

The generated SQL (show_sql=true):

1238489251275|0|9|statement|select KUNDEN_HISTORY_CHANGE_SEQ.nextval from dual

1238489251447|109|9|statement|insert into KUNDEN_HISTORY_CHANGE (KHC_COLUMN, KHC_K_ID, KHC_DATE, KHC_DESCRIPTION, KHC_NEW_VALUE, KHC_OLD_VALUE, KHC_U_ID, KHC_ID) values (?, ?, ?, ?, ?, ?, ?, ?)|


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

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.