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 (?, ?, ?, ?, ?, ?, ?, ?)|
|