Hibernate : @Table Annotation
Points To Remember
@Table Annotation is an annotation that is used to give the table level information. It can be uesd to specify the following- Table name (optional,default ="")- to set the name of the table in database
- Table schema (optional,default ="")- to set the schema of the table in database
- Table catalog (optional,default ="") -to set the catalog of the table
- Table Constraints (optional,default = []) to set the constraints on the table.
@Table( name="person", schema="ekiras", uniqueConstraints = {@UniqueConstraint(columnNames = {"id","email"})} ) public class Person { private Long id; private String name; private String email; // code }If you do not define the name property of the @Table annotation then the hibernate would have created table by name Person but now it will create the table by name person.
The person table will have the unique constraints on the columns id and email.
The person table will belong to the schema "ekiras".
No comments: