Jboss中的Hibernate JPA Peristence配置

时间:2016-11-10 15:28:03

标签: java hibernate jpa jboss jboss7.x

我转移到Hibernate Persistence而不是OpenJPA持久性,我改变了我的persistence.xml,如下所示

      <persistence-unit name="pac">
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <jta-data-source>pac</jta-data-source>
    <class>xxxx</class>
    <class>xxxx</class>
    <class>xxxxx</class>
    <class>xxxxxr</class>
    <class>xxxxx</class>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
       </persistence-unit>
    <persistence-unit name="User">
   <provider>org.hibernate.ejb.HibernatePersistence</provider>
     <jta-data-source>tUser</jta-data-source>
        <class>xxxxr</class>
      <class>xxxxx</class>
      <class>xxxxx</class>
     <exclude-unlisted-classes>false</exclude-unlisted-classes>
       <properties>
         <property name="hibernate.dialect"  value="org.hibernate.dialect.OracleDialect"/>
    <property name="hibernate.ConnectionURL" value="jdbc:oracle:thin:@xxxxxx:1521:pac811"/>
    <property name="hibernate.ConnectionDriverName" value="oracle.jdbc.OracleDriver"/>
    <property name="hibernate.ConnectionUserName" value="xyz"/>
    <property name="hibernate.ConnectionPassword" value="abc"/>      
    <property name="hibernate.connection.provider_class"
      value="org.hibernate.connection.C3P0ConnectionProvider" />
    <property name="hibernate.c3p0.max_size" value="100" />
    <property name="hibernate.c3p0.min_size" value="0" />
    <property name="hibernate.c3p0.acquire_increment" value="1" />
    <property name="hibernate.c3p0.idle_test_period" value="300" />
    <property name="hibernate.c3p0.max_statements" value="0" />
    <property name="hibernate.c3p0.timeout" value="100" />

  </properties>
我添加了org.hibernate.ejb.HibernatePersistence和c3p0属性,oracle方言在现有的持久性xml中额外更改了代码并且编译正常。 现在我担心在JBOSS中为此HibernatePersistence,oracle dialect和c3p0连接部署时需要的配置步骤是什么。 目前的Jboss服务器是Jboss redhat 6.4 我正在使用hibernate 4.2.1。如果提供这些步骤,任何有关这方面的帮助都会有所帮助。

1 个答案:

答案 0 :(得分:0)

你在JBoss,必须使用在JBoss中配置的DataSource。

删除所有这些行

 <property name="hibernate.ConnectionURL" value="jdbc:oracle:thin:@xxxxxx:1521:pac811"/>
<property name="hibernate.ConnectionDriverName" value="oracle.jdbc.OracleDriver"/>
<property name="hibernate.ConnectionUserName" value="xyz"/>
<property name="hibernate.ConnectionPassword" value="abc"/>      
<property name="hibernate.connection.provider_class"
  value="org.hibernate.connection.C3P0ConnectionProvider" />
<property name="hibernate.c3p0.max_size" value="100" />
<property name="hibernate.c3p0.min_size" value="0" />
<property name="hibernate.c3p0.acquire_increment" value="1" />
<property name="hibernate.c3p0.idle_test_period" value="300" />
<property name="hibernate.c3p0.max_statements" value="0" />
<property name="hibernate.c3p0.timeout" value="100" />

是否是您在standalone.xml中配置的数据源?