Spring配置XML文件-PersistenceProvider

时间:2018-08-07 07:34:55

标签: java xml spring spring-jdbc

我使用Alfresco 5.2,并且必须使用PostgreSQL建立第二个数据库。 Alfresco使用Spring 3.2.17-RELEASE。

Alfresco团队建议我不要使用Hibernate: https://community.alfresco.com/thread/237415-create-custom-table

所以我已经建立了一个数据库,但是总是使用Hibernate,所以我有以下配置文件,但是我不知道如何替换Persistence Provider字段:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:tx="http://www.springframework.org/schema/tx"
   xsi:schemaLocation="
      http://www.springframework.org/schema/beans 
      http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
      http://www.springframework.org/schema/tx 
      http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">

   <bean id="dataSource"
     class="org.springframework.jdbc.datasource.DriverManagerDataSource">
       <property name="driverClassName" value="org.postgresql.Driver" />
       <property name="url" value="jdbc:postgresql://localhost:5432/klinck" />
       <property name="username" value="postgres" />
       <property name="password" value="admin" />
   </bean>

    <bean id="myEmf"
     class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
       <property name="dataSource" ref="dataSource" />
       <property name="persistenceXmlLocation" value="classpath:META-INF/resources/persistence.xml" />
       <property name="persistenceUnitName" value="klinckPersistenceUnit" />
       <property name="packagesToScan" value="com.klinck.mc.bean" />
   </bean>

   <bean id="transactionManager"
     class="org.springframework.orm.jpa.JpaTransactionManager">
       <property name="entityManagerFactory" ref="myEmf" />
   </bean>
   <tx:annotation-driven />
</beans>

persistence.xml(带有提供者字段):

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
    <persistence-unit name="klinckPersistenceUnit" transaction-type="RESOURCE_LOCAL">
        **<provider>org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter</provider>// false**
        <mapping-file>META-INF/resources/orm.xml</mapping-file>
    </persistence-unit>
</persistence>

可以选择哪个持久性提供程序代替休眠提供程序? 如何运作?

0 个答案:

没有答案