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 @Id
annotation which lets you define which property is the identifier of your entity. You don't need to use the @GeneratedValue
annotation because I don't think you want hibernate to generate this property for you.
@Id
String id;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With