1 Reply Latest reply on Jun 16, 2006 10:57 AM by Atanas Todorov

    Using @SequenceGenerator ...

    Atanas Todorov Newbie

      Hi there!

      I'm using JBoss 4.0.4.GA + Oracle 10g and an individual sequence for the PKs of each enity. In some entities I need to init several fixed records with "known" identities. So I prefer to use low values for the reserved primary keys (let's say between 1 and 100) and use greater identities for the dynamic data that is going to be inserted during the regular app work...

      1. Is there a way to use the @GeneratedValue annotation, but override its behaviour when it comes to the fixed records? If I manually set the ID before trying to persist or inside a @PrePersist callback, Hibernate designedly raises an exception. So I can omit the @GeneratedValue and set the id always manually (getting the sequence NEXTVAL when necessary), but it is not the cleanest way to achieve the goal. Is there some better way?

      2. To reserve some range for the initial identities, the "initialValue" attribute in the @SequenceGenerator annotation would be a perfect solution, but it does not seem to work?