Hibernate newbie here. I am working on a simple Hibernate mapping file.
When I am using the xml approach, I set the generator class to assigned.
There are certain logic that must be checked before an employee id is assigned so I cant generate it
automatically.
<id name="id" type="string" column="emp_id">
<generator class="assigned">
</generator>
</id>
But I am also studying the annotation type and annotation seems to be in thing nowadays as frameworks are moving away from
configuration files. But I cant find any generation type to match the assigned value
public class Employee{
String id;
@column(name="emp_id", unique=true)
public String getID(){
return id;
}
}
Does this mean that I dont need to add any sequence generator annotation when it is assigned? Thanks
Just use the
@Idannotation which lets you define which property is the identifier of your entity. You don’t need to use the@GeneratedValueannotation because I don’t think you want hibernate to generate this property for you.