Hi,
I'm using the Oracle sequence generation to insert a new row into my detail tables.
I noticed that Hibernate generates 2 calls to the db for each insert..
1. To generate sequence.nextval
2. The actual insert
Is there any way that I could reduce this to just one call, and still continue using sequences? We have a home-grown persistence layer that I want to replace and that uses the sequence.nextval within the insert statement, thereby reducing one call. This is having a decent performance impact if I try to insert 100 + rows (about 2 seconds slower).
Thank you for your help..
Hibernate version: 2.1
Code:
Mapping documents:
<id
name="tradeOrderDetailId"
type="java.lang.Integer"
column="TRADE_ORDER_DETAIL_ID"
>
<meta attribute="field-description">
@hibernate.id
generator-class="sequence"
type="java.lang.Integer"
column="TRADE_ORDER_DETAIL_ID"
@hibernate.generator-param
name="sequence"
value="trade_order_detail_seq"
</meta>
<generator class="sequence">
<param name="sequence">trade_order_detail_seq</param>
</generator>
</id>
Name and version of the database you are using: Oracle 9iThe generated SQL (show_sql=true):
[java] Hibernate: select trade_order_detail_seq.nextval from dual
[java] Hibernate: insert into TRADE_ORDER_DETAIL (TRADER_NAME, SUIT_CHECK, SOLICITATION, SETTLEMENT_TYPE, DEALER_PR
ICE, QTY_TYPE, PRICING_METHOD, CUSTOMER_CONTACT, ORDER_DURATION, NOTIFY_ISSUER, IS_PROJECTED_SETTLEMENT, INFLATION_ACCRU
AL, INDEX_FACTOR, FACTOR_DATE, COMMISSION_TYPE, CREATION_DATE, UPDATE_DATE, CREATED_BY, DEALER_CONTACT, EXCHANGE, OPEN_Q
TY, QUOTE_DISCOUNT, RECORD_LOCKED_TIME, INVENTORY_ACCOUNT, COMMENTS, AGENT_DEALER, ERROR_CODE, ERROR, NUMBER_OF_SUB_ACCO
UNTS, CHANNEL, CONFIRM_MESSAGE, IS_BOOKED, UPDATED_BY, LORD_MESSAGE, BOOKING_MESSAGE, TRADE_ORDER_ID, TRADE_ORDER_DETAIL
_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?)
[/code]