Creating a Hibernate archive
2 June 2008Consider 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.
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="org.jboss.roster.Player" table="PlayerBean"> <id name="id" type="string" column="playerID"> <generator class="assigned" /> </id> <property name="position" type="string" column="POS" /> <property name="name" type="string" column="name" /> <property name="salary" type="float" column="salary" /> </class> </hibernate-mapping>
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.
<server> <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=Hibernate"> <attribute name="DatasourceName">java:/DefaultDS</attribute> <attribute name="Dialect">org.hibernate.dialect.HSQLDialect</attribute> <attribute name="SessionFactoryName">java:/hibernate/SessionFactory</attribute> <attribute name="CacheProviderClass"> org.hibernate.cache.HashtableCacheProvider </attribute> <!-- <attribute name="Hbm2ddlAuto">create-drop</attribute> --> </mbean> </server>
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: Creating a Hibernate archive