Identity Algorithm

Identity Algorithm

Identity algorithm is able to generate primary key values on the basis on the underlying database table provided identity column.


Identity column is a primary key Column with “auto_increment” capability.

  • This algorithm is able to provide the primary key values of the data types like short, int, long, etc.
  • This algorithm is not required any input parameter.
  • This algorithm is supported by almost all the databases which are supporting Identity column.
    • E.g MySQL.
  • To represent this algorithm, Hibernate has provided “identity” as short name and “” as predefined class.
sql>create table emp(id primary key auto_increment, emp_name varchar2(30), salary float, address varchar2(20));


<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC 
"-//Hibernate/Hibernate Mapping DTD//EN"

	<class name="com.ashok.hibernate.sample.model.Employee" table="emp">
		<id name="id" type="int" column="id">
			<generator class="identity" />
		<property name="empName" column="emp_name" type="string" />
		<property name="address" column="address" type="string" />
		<property name="salary" column="salary" type="float" />
Identity Algorithm
Scroll to top