JBoss 5.1:使用JPA进行Hibernate [英] JBoss 5.1: Hibernate with JPA
问题描述
我们也使用Java 1.6和JPA 2.0以及Hibernate 3.6作为提供者。
我的问题是:
- 是否可以在JBoss 5.1中使用Hibernate 3.6+。如果是,那么怎么做?
- JPA 2.0呢?我知道JBoss 5.1具有JPA 1.0兼容性。我们可以使用JPA2吗?
由于我们无法对JBoss安装进行任何类型的配置,所有修复都需要完成在我们的应用程序中。
在此先感谢,
JassB
$ b
content:
<?xml version =1.0encoding =UTF-8 >?;
< classloading xmlns =urn:jboss:classloading:1.0
$ b $ domain =$ UNIQUE_DOMAIN_NAME
export-all =NON_EMPTY
import-all =false
parent-first =false>
< / classloading>
<2>修改$ JBOSS_INSTALL_DIRECTORY / jboss-as / server / $ PROFILE / conf / bootstrap / deployers。 xml,并在结尾处添加以下内容:
< bean name =IgnoreFilesDeployer
class =org.jboss.deployers.vfs.spi.deployer.AbstractIgnoreFilesDeployer
< / bean>
3)在META中创建一个文件JBOSS-IGNORE.TXT -INF文件夹,包含以下内容:
lockquote
WEB-INF / classes / META-INF / persistence.xml
4)我将persistence.xml重命名为spring-persistence.xml,并将这个文件添加到context.xml中:
< bean id =entityManagerFactoryclass =org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean>
< property name =persistenceXmlLocationvalue =classpath:/META-INF/spring-persistence.xml/>
....
< / bean>
5)我也修改了spring-persistence.xml (保存在webapp \META-INF文件夹中的persistence_2_0.xsd)作为
< persistence version =2.0
xmlns =http://java.sun.com/xml/ns/persistence
xmlns:xsi =http://www.w3.org/2001/XMLSchema-instance
xsi :schemaLocation =file:///persistence_2_0.xsd
http://java.sun.com/xml/ns/persistence\">
....
< /持久性>
I've got two questions to ask regarding JBoss 5.1. We are in process of migrating from JBoss 4.2 to JBoss 5.1.
We are also using Java 1.6 and JPA 2.0 with Hibernate 3.6 as the provider.
My questions are:
- Is it possible to use Hibernate 3.6+ with JBoss 5.1. If yes, then how?
- What about JPA 2.0? I know that JBoss 5.1 comes with JPA 1.0 compatibility. Can we use JPA2?
And as we can not do any kind of configuration to the JBoss installation, all the fixes need to be done in our application only.
Thanks in advance, JassB
Do this:
1) Add jboss-classloading.xml to /src/main/webapp (I am using Maven):
content:
<?xml version="1.0" encoding="UTF-8"?>
<classloading xmlns="urn:jboss:classloading:1.0"
domain="$UNIQUE_DOMAIN_NAME"
export-all="NON_EMPTY"
import-all="false"
parent-first="false">
</classloading>
2) Modify $JBOSS_INSTALL_DIRECTORY/jboss-as/server/$PROFILE/conf/bootstrap/deployers.xml, and add the following at the end:
<bean name="IgnoreFilesDeployer" class="org.jboss.deployers.vfs.spi.deployer.AbstractIgnoreFilesDeployer" </bean>
3) Create a file JBOSS-IGNORE.TXT in the META-INF folder with following content:
WEB-INF/classes/META-INF/persistence.xml
4) I've renamed my persistence.xml to spring-persistence.xml and added this file in the context.xml as:
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="persistenceXmlLocation" value="classpath:/META-INF/spring-persistence.xml"/> .... </bean>
5) I;ve also modified the spring-persistence.xml (saved persistence_2_0.xsd in webapp\META-INF folder) as
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="file:///persistence_2_0.xsd
http://java.sun.com/xml/ns/persistence">
....
</persistence>
这篇关于JBoss 5.1:使用JPA进行Hibernate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!