Increment Algorithm

Increment Algorithm
  • This primary key generation algorithm is able to generate primary key value by incrementing max value of the primary key column.
    • New_Val = max(PK_Column) + 1
  • This algorithm is able to generate primary key values of the data types like short, int, long, etc.
  • This algorithm is not required any input parameter to generate primary key values.
  • This algorithm is supported by almost all the databases which are supporting numeric values as Primary key values.
  • This algorithm is represented by Hibernate Software in the form of a short name “increment” and in the form of a predefined class like “org.hibernate.id.IncrementGenerator”.

E.g

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC 
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
	<class name="com.ashok.hibernate.sample.model.Employee" table="emp">
		<id name="id" type="int" column="id">
			<generator class="org.hibernate.id.IncrementGenerator" />
		</id>
		<property name="empName" column="emp_name" type="string" />
		<property name="address" column="address" type="string" />
		<property name="salary" column="salary" type="double" />
	</class>
</hibernate-mapping>
Increment Algorithm


Scroll to top