การใช้งาน Hibernate กับ JBoss ตอนที่ 1
posted on 01 Dec 2004 11:38 by somkiatเริ่มต้นการใช้งาน Hibername 2.0ใน JBoss 4.0
1. เตรียม JDBC Datasource
2. เตรียม libary filed ของ Hibernate ดังนี้
- cglib.jar
- commons-collections.jar
- commons-logging.jar
- commons-lang.jar
- jcs.jar
- odmg.jar
- hibernate.jar
- don4j.jar
3.สำหรับการติดตั้ง Hibernate นั้นเราจะpacked ไว้ใน SARfile (Service ARchive File)ซึ่งมีโครงสร้างดังนี้
com.test.spns.Player
mappings/Player.hbm.xml
META-INF/
4. Config ใน service file
| <server> <mbean code="net.sf.hibernate.jmx.HibernateService" name="jboss.jca:service=HibernateFactory, name=HibernateFactory"> <depends>jboss.jca:service=RARDeployer</depends> <depends>jboss.jca:service=LocalTxCM,name=MySqlDS</depends> <!-- Make it deploy ONLY after DataSource had been started --> <attribute name="MapResources">mappings/Player.hbm.xml</attribute> <attribute name="JndiName">java:/hibernate/HibernateFactory</attribute> <attribute name="Datasource">java:/MySqlDS</attribute> <attribute name="Dialect">net.sf.hibernate.dialect.MySQLDialect</attribute> <attribute name="TransactionStrategy">net.sf.hibernate.transaction.JTATransactionFactory</attribute> <attribute name="TransactionManagerLookupStrategy">net.sf.hibernate.transaction.JBossTransactionManagerLookup</attribute> <attribute name="UseOuterJoin">false</attribute> <attribute name="ShowSql">false</attribute> <attribute name="UserTransactionName">UserTransaction</attribute> </mbean> </server> |
5. ทำการ packed SAR file
6. CopySAR fileไปยัง${JBOSS_HOME}/server/default/deploy เพื่อทำการ deploy

#1 By Sarayut (192.55.18.36 /10.7.67.87) on 2005-06-15 15:25