Java Persistence with Hibernate Part 4 – Create the Mapping File and Configuration File
August 15, 2009
Leave a comment
We need to tell Hibernate how our persistent class(Student.java) maps to our table(student_table) for Hibernate to be able to load and persist(save) data.
Create the Mapping File
The basic structure of a mapping file is like this:
< ?xml version="1.0" encoding="UTF-8"?>
< !DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate -mapping package="com.phoenixone.hibernate.model">
<class name="com.tutorial.enrollment.model.Student" table="student">
<id name="id" column="student_id">
<generator class="org.hibernate.id.enhanced.SequenceStyleGenerator" />
</id>
<property name="firstName" column="first_name" />
<property name="lastName" column="last_name" />
</class>
</hibernate>
Read more…
Categories: Hibernate, Java
Hibernate, Java, Object Relational Mapping, Persistence

Recent Comments