Hibernate - Mapping files

3 August 2008

Mapping files are there to map entities with the database tables. In this post, I will present 2 sample mapping files.

Mapping file for MySql is given below:

<?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>
 <class name="com.domain.example.Student" table="student">
 <id name="id" column="id" type="java.lang.Integer">
 <generator class="increment"/>
 </id>
 <property name="name" column="name" type="java.lang.String" />
 <property name="subject" column="taste" type="java.lang.String" />
 </class>
</hibernate-mapping>

Mapping file for Posgres is given below:

<?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>
 <class name="com.domain.example.Student" table="student">
 <id name="id" column="id" type="java.lang.Integer">
		<generator class="sequence">
				<param name="sequence">student_id_seq</param>
			</generator>
 
 </id>
 
 <property name="name" column="name" type="java.lang.String" />
 <property name="subject" column="taste" type="java.lang.String" />
 </class>
</hibernate-mapping>

del.icio.us:Hibernate - Mapping files  digg:Hibernate - Mapping files  spurl:Hibernate - Mapping files  wists:Hibernate - Mapping files  simpy:Hibernate - Mapping files  newsvine:Hibernate - Mapping files  blinklist:Hibernate - Mapping files  furl:Hibernate - Mapping files  reddit:Hibernate - Mapping files  fark:Hibernate - Mapping files  blogmarks:Hibernate - Mapping files  Y!:Hibernate - Mapping files  smarking:Hibernate - Mapping files  magnolia:Hibernate - Mapping files  segnalo:Hibernate - Mapping files  gifttagging:Hibernate - Mapping files

Top Of Page | Trackback

If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.

It will look like this: Hibernate - Mapping files

Leave a Reply