Question - Mention some important annotations used for Hibernate mapping?
Answer -
Hibernate supports JPA annotations. Some of the major annotations are:
- javax.persistence.Entity: This is used with model classes to specify they are entity beans.
- javax.persistence.Table: It is used with entity beans to define the corresponding table name in the database.
- javax.persistence.Access: Used to define the access type, field or property. The default value is field and if you want Hibernate to use the getter/setter methods then you need to set it to a property.
- javax.persistence.Id: Defines the primary key in the entity bean.
- javax.persistence.EmbeddedId: It defines a composite primary key in the entity bean.
- javax.persistence.Column: Helps in defining the column name in the database table.
- javax.persistence.GeneratedValue: It defines the strategy to be used for the generation of the primary key. It is also used in conjunction with javax.persistence.GenerationType enum.