1.student.hbm.xml Configuration
Uuid
Uses a 128-bit UUID algorithm to generate identifiers of type String that's unique within a network (the IP address is U SED). The UUID is encoded as a string of hexadecimal digits in length.
The ID must be of type string. Finally, the ID generated in MySQL is a varchar type.
native
Selects identity , sequence or hilo depending upon the capabilities of the underlying database.
2.Annotation Configuration _identity_sequence
@Id @generatedvalue (strategy=generationtype.identity) public int getId () {return Id;}
Sequence generator, using the Oracle database.
@SequenceGenerator ( name= "Teacherseq", Sequencename= "teacherseq_db") added in front of class
@GeneratedValue(strategy=generationtype.sequence,generator="Teacherseq") added before the method
3.TableGenerator (cross-database platform)
@javax. Persistence.tablegenerator (
Name= "Teacher_gen",
Table= "Generator_table",
Pkcolumnname= "Pk_key",
Valuecolumnname= "Pk_value",
Pkcolumnvalue= "Teacher",
Allocationsize=1
)
Student.hbm.xml
<?xml version= "1.0" encoding= "UTF-8"? ><! DOCTYPE hibernate-mapping Public "-//hibernate/hibernate mapping DTD 3.0//en" "Http://www.hibernate.org/dtd/hiberna Te-mapping-3.0.dtd ">
Teacher.hbm.xml
<?xml version= "1.0" encoding= "UTF-8"?><! DOCTYPE hibernate-mapping public "-//hibernate/hibernate mapping DTD 3.0//en" "Http://www.hibernate.org/dtd /hibernate-mapping-3.0.dtd ">
Hibernate ID Generation policy configuration