เริ่มต้นการใช้งาน Hibername 2.0ใน JBoss 4.0

1. เตรียม JDBC Datasource

2. เตรียม libary filed ของ Hibernate ดังนี้
  1. cglib.jar
  2. commons-collections.jar
  3. commons-logging.jar
  4. commons-lang.jar
  5. jcs.jar
  6. odmg.jar
  7. hibernate.jar
  8. 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

Comment



smilebig smileopen-mounthed smileconfused smilesad smileangry smiletonguequestionembarrassedsurprised smilewinkdouble winkcry

Tweet

ทำยังไงถึงจะสามารถเอา hibernate2 mapping กับ Oracle ได้ครับ ต้องติดตั้ง plugin หรือ lib อะไรเพิ่มหรือเปล่า

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

#2 By (58.11.40.10) on 2005-06-30 13:21

ขอตอนที่ 2 ด้วยคร้าบ

#3 By เดวิด on 2005-11-23 13:29

#4 By (203.209.26.240) on 2007-02-19 10:49

ขอบคุณครับ
พี่ครับ ผมรบกวนขอตัวอย่างโค้ด การใช้ hibernate กับ web application ส่งมาที่ machine_eye@hotmail.com
ครับ

ตอนนี้ผมกำลังงงพวกไฟล์ XML ต่างๆอยู่ครับ ขอบคุณครับ

#5 By ฟ้า (124.122.209.162) on 2009-08-22 09:05