UUID Algorithm

UUID [Universal Unique Identity] Algorithm
  • UUID algorithm is able to generate primary key value on the basis of System IP-Address, JVM Startup time, Current System time, etc. factors.
  • This algorithm is able to generate primary key value in the form of 32 bit hexa decimal value.
  • This algorithm is able to generate primary key value of the data type like String.
  • This algorithm is represented by Hibernate software in the form of a short name “uuid” and a predefined class name “org.hibernate.id. UUIDHexGenerator”.
  • This algorithm is supported by almost all the databases which are supporting String type primary key values.
  • This algorithm is not required any input parameters, but, it must required “varchar” type primary key column with 32 column size minimum in database table.

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.UUIDHexGenerator"/>
		</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>
UUID Algorithm


Scroll to top