This content has been marked as final.
Show 2 replies
-
1. Re: From Tomcat to JBoss, a hibernate application
samfra Jan 14, 2005 4:41 AM (in response to leebase)I think you don't know how to use Hibernate with jboss.
Read first the doc...
there is no hibernate.cfg.xml but an hibernate-service.xml that must be include in a HAR archive. -
2. Re: From Tomcat to JBoss, a hibernate application
beyarecords Jan 14, 2005 5:28 AM (in response to leebase)Lee,
in my hibernate.har folder the structure is:
hibernate.har
-hibernate.cfg.xml
-META-INF/hibernate-service.xml
-test/ (*.hbm.xml,*.class)
-WEB-INF/lib/here I have my database driver and ehcache.(jar/xml)
hibernate.cfg.xml<hibernate-configuration> <session-factory> <!-- Use a Tomcat JNDI datasource --> <!--<mapping resource="test/User.hbm.xml"/> <mapping resource="test/Artist.hbm.xml"/> <mapping resource="test/ArtistImages.hbm.xml"/> <mapping resource="test/Stock.hbm.xml"/> <mapping resource="test/StockImages.hbm.xml"/> <mapping resource="test/Order.hbm.xml"/> <mapping resource="test/OrderItem.hbm.xml"/>--> <class-cache class="test.Order" usage="transactional"/> <collection-cache collection="test.Order.OrderItems" usage="transactional"/> <class-cache class="test.Artist" usage="transactional"/> <collection-cache collection="test.Artist.ArtistImages" usage="transactional"/> <class-cache class="test.User" usage="transactional"/> <collection-cache collection="test.User.ArtistChoice" usage="transactional"/> <class-cache class="test.Stock" usage="transactional"/> <collection-cache collection="test.Stock.StockImages" usage="transactional"/> </session-factory> </hibernate-configuration>
I have quoted out the mapping resource lines because the *.hbm.xml files are automatically picked up. But it will not harm if you do decide to list them.
hibernate-service.xml<server> <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=Hibernate"> <depends>jboss.jca:service=RARDeployer</depends> <depends>jboss.jca:service=LocalTxCM,name=PostgresDS</depends> <attribute name="SessionFactoryName">java:/hibernate/SessionFactory</attribute> <attribute name="DatasourceName">java:/PostgresDS</attribute> <attribute name="Dialect">net.sf.hibernate.dialect.PostgreSQLDialect</attribute> <attribute name="CacheProviderClass">net.sf.ehcache.hibernate.Provider</attribute> <!-- Turn this on and set the value to update if you want all the tables to be updated by hibernate --> <!-- or create-drop if you want the tables to be re-generated --> <attribute name="Hbm2ddlAuto"></attribute> <attribute name="ShowSqlEnabled">true</attribute> <attribute name="JdbcBatchSize">25</attribute> </mbean> </server>
I hope this helps
beya!