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
If we are using mysql it would be better to use the @GenericGenerator of increment strategy.
increment - This sort of strategy supports by MySql.
@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 listOfAddress = new ArrayList<>();
When I have used the sequence strategy with MySql I came across an issue where my ADDRESS_ID is not getting incremented properly.