Assigned Algorithm
- This algorithm is default primary key generation algorithm in hibernate applications, it will not required configurations in mapping file.
- This algorithm will not have its own mechanism to generate primary key value , it will request to Client Application to provide primary key value explicitly.
- This algorithm is able to support for any type of primary key values like short, int, long, String, etc.
- This algorithm is supported by almost all the databases like Oracle, MySQL, DB2, etc.
- This algorithm is not required any input parameter.
- This algorithm is represented by Hibernate in the form of a predefined class “org.hibernate.id.Assigned”.
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="assigned" /> </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>
Assigned Algorithm