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
The Support for 'hilo' generator has been removed. For additional information, this link gives you the deprecated list.
To overcome this, you can simply use sequence generator. This will solve your problem.
@Entity
@Table(name = "USER_DETAILS")
public class UserDetails {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int userId;
private String userName;
@ElementCollection
@JoinTable(name="USER_ADDRESS",
joinColumns=@JoinColumn(name="USER_ID")
)
@GenericGenerator(name = "sequence-gen", strategy = "sequence")
@CollectionId(columns = { @Column(name="ADDRESS_ID") }, generator = "sequence-gen", type = @Type(type="long"))
private Collection<Address> address = new ArrayList<Address>();
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public Collection<Address> getAddress() {
return address;
}
public void setAddress(List<Address> address) {
this.address = address;
}
}