3

I am using Oracle as backend and when i try to insert any entry the sequence which hibernate is generating is of the order of "50010255" but in my db the current value of SEQ_AD_WORK sequence shows only "1000221" i am unable to figure out how that can happen.

following are my configurations

   <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.query.startup_check">false</prop>
            <!-- 
            <prop key="hibernate.hbm2ddl.auto">create</prop>
            -->
        </props>
    </property>`

   @Id
@Column(name = "ITEM_ID", unique = true, nullable = false,  scale = 0)
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="SEQ_AD_WORK")
 @SequenceGenerator(name="SEQ_AD_WORK", sequenceName="SEQ_AD_WORK")
public Long getAdWorkItemId() {
    return this.adWorkItemId;
}
1
  • after enabling Debug i can see that hibernate is actually fetching the correct nextval from DB by after fetching it is converting into other value using rg.hibernate.id.SequenceHiLoGenerator any idea why this behaviour? Commented Jun 30, 2011 at 7:15

1 Answer 1

5

@Dhirendra: try this:-

@SequenceGenerator(name="SEQ_AD_WORK",sequenceName="SEQ_AD_WORK",,allocationSize=1)

SequenceHiLoGenerator is the default sequence generator for JPA and the default allocationSize value of 50,

Sign up to request clarification or add additional context in comments.

1 Comment

thank's alot i got it working. just couldn't post the answer because i do not have enough reputation to post :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.