Hibernate - Mapping files
3 August 2008Mapping 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>
Related Posts:
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