Every entity in Hibernate has to have a field which maps to the primary key of a table in a database. Such a field is identified by the @Id annotation. Such a field is also known as the identifier field. Identifiers are of two types: Simple Identifiers and Generated Identifiers.  Simple Identifiers: This is the most straightforward way of mapping. The mapping is done by using the @Id annotation. Simple identifiers map to a single property of the below types:  Any Java primitive type  Any primitive wrapper class type  java.lang.String  java.util.Date  java.sql.Date  java.math.BigDecimal  java.math.BigInteger  Let us look at a small example:  @Entity
publicclassStudent {
@Id
privatelongstudentId;
//constructors, getters, setters
}  Generated Identifiers: When the primary key values have to be generated automatically, @GeneratedValue annotation is added. Generated identifiers are of 4 types:  Auto: This is the default generation type. Values are determined based on the types of the primary key value.  Identity: This type is dependent on the IdentityGenerator which expects auto-incremented or auto generated identity column values from the database  Sequence: A class named SequenceStyleGenerator is provided by Hibernate to work with sequence – based id. This generator uses sequences if they are supported by the database.  Table: This type of generator generates values by using the underlying database table.