gmanoj77 wrote:
In @PrePersist method you can query the table and get the next value of your Id and set it in the object, this way you wont need the sequence generator.
Hi gmanoj77,
Can you pls. be more specific and provide a code snippet for this? I have the "
Id" column, being the primary key, in my Employee entity bean with
@GeneratedValue(strategy = auto)" annotation. Thus I do not (and probably can not) need to set the Id value while inserting a new record - hibernate does that for me.
Now if I have a @PrePersist method, how can I set this Id value?
Also do you mean I have to do this setting for every new insert? - then it will be a overkill.
Thanks