GUID Algorithm
- GUID algorithm is able to generate primary key values on the basis of the underlying database provided identity column with String type.
- This algorithm is represented in the form of a predefined class org.hibernate.id.GUIDGenerator and in the form of a short name like “guid”.
- This algorithm is not requires any input parameters to generate primary values.
- This algorithm is supported by the databases which are supporting string type id columns.
<?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.GUIDGenerator"/> </id> <property name="empName" column="emp_name" type="string" /> <property name="address" column="address" type="string" /> <property name="salary" column="salary" type="float" /> </class> </hibernate-mapping>
GUID Algorithm