mercredi 1 juillet 2015

How to generate Custom Id using hibernate while it must be primary key of table

Here is my pojo class

@Entity

public class Department {


@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)

@Column(name="Department_Id")

private Integer deptId;


@Column(name="Department_Name",unique=true,nullable=false)
private String deptName;


@Column(name="Department_Description")
@NotNull
private String deptDesc;
   //geters and setters

What i want is that department_id must be primary key of this Department table and entries for this key must be as DEP0001, DEP0002,DEP003

Aucun commentaire:

Enregistrer un commentaire