I already have a entity class with id as Integer. As requirement we need to add a GUID to this that wont be PK for now. But should get auto populated whenever a entity is created new. (Existing will have this new Column GUID as NULL). GUID is not getting populated(coming as NULL) with each new entry in this table. Please help.
@Entity
@Table(name = "TABLEA")
public class TableA
{
private int id;
private String guid;
@Id
@GenericGenerator(name = "sequence", strategy = TableNameSequenceGenerator.TABLE_NAME_SEQUENCE_GENERATOR)
@GeneratedValue(generator = "sequence")
@Column(name = "ID")
public int getId()
{
return id;
}
public void setId(int id)
{
this.id = id;
}
@GenericGenerator(name = "guidGenerator", strategy = "guid")
@GeneratedValue(generator = "guidGenerator")
@Column(name = "GUID")
public String getGuid()
{
return guid;
}
public void setGuid(String guid)
{
this.guid = guid;
}
}