I am new to hibernate. What I am trying to do is use @CollectionId
to generate an identifier for my Address class. I have used Collection
interface for
This is what works for apps on PostgreSQL. Though I have not tested it, it should work for all DBs. Note that increment-gen
is used not sequence.
@ElementCollection
@JoinTable( name = "user_address", joinColumns = @JoinColumn( name = "user_id"))
@GenericGenerator(name="increment-gen",strategy="increment")
@CollectionId( columns = { @Column( name ="address_id") }, generator ="increment-gen", type =@Type( type ="long"))
private Collection listOfAddresses = new ArrayList();