JBoss-IDE 1.2.2 Introduction (Hibernate) 4

zhaozj2021-02-16  59

JBoss-IDE 1.2.2 Introduction (Hibernate) 4:

6. Now set XDoclet, first add a JBoss-Service-Custom.xdt file in the SRC / META-INF in the Tutorial project, as follows: jboss.jca: service = localtxcm, name = MySQLDS

Net.sf.hibernate.cache.treecacheProvider

Then right-click Tutorial Project, select 'Properties', select 'XDoclet Configuration', select 'Add Standard' in the windows of the upper right, select 'Standard Hibernate' Press 'OK', 'Standard Hibernate' can be changed to 'Hibernate' Press' OK '. Click on this' Hibernate', click 'Hibernatedoclet' in the window below, and the extensive information can be seen in the window of the right, we choose 'mergedir', fill in 'src / meta-inf. , As shown below:

Standard's Hibernatedoclet already has the properties of 'fileset' and 'Hibernate', click 'Hibernate', select 'version of' Version 'in the right side of the window' 2.0 '. Right click on' Hibernatedoclet 'to choose' add '->' fileset ', Choose 'Dir' Fill in 'SRC / TUTORIAL / Hibernate', select 'Include' Fill in '** / *. HBM.XML'. Right click on 'Hibernatedoclet' Choose 'Add' -> 'JBossService', select 'Datasource 'Fill in' java: / mysqlds '(depending on step 1 setting Datasource), select' DESTDIR 'to fill in' src / meta-inf ', select' DIALECT 'to fill in' net.sf.hibernate.Diaalect.mysqldiaAlactory ', Select' JNDINAME 'Fill in' Java: / Hibernate / HibernateFactory ', select' ServiceName 'Fill in' Hibernate ', select' Showsql 'Fill in' false ', select' TransactionManagerStrateGy 'to fill in' net.sf.hibernate. transaction.JBossTransactionManagerLookup ', selected from the group' transactionStrategy 'fill' net.sf.hibernate.transaction.JTATransactionFactory ', selected from the group' useOuterJoin 'fill' false ', selected from the group' userTransactionName 'fill' UserTransaction ', by' OK ', as in FIG. :

XDoclet settings are finally completed, and now you can run. Right-click Tutorial's item to select 'Run XDoclet', then add a 'Num.hbm.xml' file in tutorial.hibernate, in SRC / META-INF I will add a 'jboss-service.xml', as shown in the figure.

This 'jboss-service.xml' has a small problem, which is the xdoclet corresponding to hibernate's bug. When you open 'jboss-service.xml', you will see the following code:

jboss.jca: service = rarDeployer

Tutorial / Hibernate / Num.hbm.xml

Java: / Hibernate / HibernateFactory

Java: / mysqlds

Net.sf.hibernate.Dialect.mysqldiaAlaforct

false

false

UserTransaction

Net.sf.hibernate.Transaction.jtatransActionFactory

Net.sf.hibernate.transaction.jbosstransactionManagerLookup

jboss.jca: service = localtxcm, name = mysqlds

Net.sf.hibernate.cache.treecacheProvider

Tail 2 and tail three lines are outside , so you have to manually put these two rows within ... . Finally press saved.

7. Now let's set the package. Right click on Tutorial Project, select 'Properties', and then select' Packaging Configuration ', because Hibernate wants to include .hbm.xml image file, we want to be on the right hand side in' fiboejb. The '/ jboss_ide_tutorial / bin' (ie tutorial / tutorial / bin) under Jar ', including the set of' tutorial / hibernate / *. HBM.XML, TUTORIAL / Hibernate / *. Class' in the tutorial / hibernate package, Right-click '/ JBoss_IDE_TUTORIAL / BIN' Choose 'Edit': The SAR service setting of JBoss is set, and the windows of the right hand are selected in the right hand, and the 'add archive' fills in 'Hibernatestartup.sar' Press 'OK'. Hibernatestartup.sar 'Choose' JBoss-Service.xml '' /JBoss_IDE_TUTORAL/SRC /META-INF/JBOSS-SERVICE.XML ', Prefix Fill in the Tutorial Meta-INF folder META-INF ', press' OK '. Because this setting is to be set before' FiboApp.ear ', you have to press the' file on 'file' on 'fiboApp.ear' by right hand:

In 'fiboApp.ear' package settings, we have to add this' hibernatestartup.sar ', right-click' FiboApp.ear 'Choose' add file 'fill in' /jboss_ide_tutorial/hibernatestartup.sar 'after filling in the project' OK '. Al remember to include the' jboss-app.xml 'file in JBoss SAR service, right-click' FiboApp.ear 'Choose' / jboss_IDE_TUTORIAL / SRC / META-INF / JBOSS -app.xml ', prefix fills in' meta-inf ', press' OK', then press' OK ':

The code of 'jboss-app.xml' is as follows:

localhost: loader = fiboApp.ear

hibernatestartup.sar

Packaging settings are finally completed, and now you can run. Right-click Tutorial project to select 'Run Packaging'. After success, you should add a 'Hibernatestartup.sar' file, as shown:

8. Now we can try it, first start JBoss -> deploy 'fiboApp.ear' to jboss, in Browser input 'http://127.0.0.1:8080/fibo', then enter '50', you can see To the following results, the examples in the JBoss-Ide tutorial are the same, but Hibernate is used inside.

postscript:

The shortcomings of this example is to generate bug in jboss-service.xml. Whenever the 'Run XDoclet' is completed, it is necessary to manually modify jboss-service.xml. Online seems to have FIX, but because it is too lazy to find. Finally, There may be many places to go wrong or missing, I hope everyone can correct and give more opinions, thank you!

Reference:

转载请注明原文地址:https://www.9cbs.com/read-21972.html

New Post(0)