开发者

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 clas开发者_JAVA技巧s="sequence">
          <param name="sequence">SEQUENCE_1</param>
       </generator>
    </id>      
</class>


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?
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜