Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

configure id sequence hibernate generator

Can I configure Hibernate not to do the select seq.nextval from dual as separate call before the actual insert ?

org.hibernate.jdbc.AbstractBatcher about to open PreparedStatement (open PreparedStatements: 0, globally: 0) 
org.hibernate.SQL select SEQUENCE_1.nextval from dual 
org.hibernate.id.SequenceGenerator auditor50 - Sequence identifier generated: 122797 
org.hibernate.jdbc.AbstractBatcher auditor50 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1) 

<class..>
    <id column="ID" name="id" type="long">
       <generator class="sequence">
          <param name="sequence">SEQUENCE_1</param>
       </generator>
    </id>      
</class>
like image 925
Rodriguez Avatar asked Dec 13 '25 01:12

Rodriguez


1 Answers

I don't think this is possible. But I don't know what difference it would make. If you want to do this for performance reasons:

  1. Have you measured a significant difference between both approaches?
  2. Do you know that the sequence ID generator of Hibernate is in fact a hilo sequence ID generator, and that it only gets the next value every N inserts (N defaulting at 50, IIRC), making it certainly faster than you might think?
like image 129
JB Nizet Avatar answered Dec 15 '25 15:12

JB Nizet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!