View RSS Feed

My Java Tips

Creating a Hibernate archive

Rate this Entry
by , 11-06-2011 at 05:20 PM (2169 Views)
Consider a simple POJO with no direct coupling to Hibernate. The details of the Hibernate mapping will be specified in the Player.hbm.xml file.

Player.hbm.xml is shown below.

"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
<class name="org.jboss.roster.Player" table="PlayerBean">
<id name="id" type="string" column="playerID">
<generator class="assigned">
<property name="position" type="string" column="POS"></property>
<property name="name" type="string" column="name"></property>
<property name="salary" type="float" column="salary"></property>

Apart from mapping file, there needs to be a file that creates MBean which will manage hibernate configurations. We call that file hibernate-service.xml.

<mbean code="org.jboss.hibernate.jmx.Hibernate">name="jbo ss.har:service=Hibernate"&gt;
<attribute name="DatasourceName">java:/DefaultDS</attribute>
<attribute name="Dialect">org.hibernate.dialect.HSQLDialect</attribute>
<attribute name="SessionFactoryName">java:/hibernate/SessionFactory</attribute>
<attribute name="CacheProviderClass">
<!-- <attribute name="Hbm2ddlAuto">create-drop</attribute> -->

Submit "Creating a Hibernate archive" to Facebook Submit "Creating a Hibernate archive" to Digg Submit "Creating a Hibernate archive" to Submit "Creating a Hibernate archive" to StumbleUpon Submit "Creating a Hibernate archive" to Google

Tags: None Add / Edit Tags
Hibernate , XML