Ok, now I know whats going on.
To summarize, I thought that a generated id coming from a sequence in EJB would
be the same as the physical value of the sequence. But the sequence generator
actually takes the value from the database sequence and multiplies it by the
allocationSize. As long as every program, (or chunk of code) using that
sequence uses the same multiplier you will be safe. The SequenceHiLoGenerator
keeps the last sequence number in memory and just increments the sequence
number in memory, and pulls a new physical sequence when it uses allocationSize
numbers since the last pull from the physical sequence.
If I want the generator to produce the same number as the sequence (so the code
will not conflict with other non-java code using the sequence), than I can set
the allocationSize to 1. Then I will not need a hibernate specific annotation.
This works for me:
| @Id
| @GeneratedValue(strategy=GenerationType.SEQUENCE,
generator="VNDR_ID_SEQ")
| @SequenceGenerator(name="VNDR_ID_SEQ", sequenceName="VRAP.VNDR_ID_SEQ",
allocationSize=1)
| @Column(name="VNDR_ID")
| public int getId() {
| return id;
| }
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3961446#3961446
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3961446
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user