Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Partitioning with Spring managed data sources

Hello,

I am wondering if partitioning with Spring managed data sources is supported with Eclipselink 2.3.2?  It seems to work ok, and I'm not sure if the error I see is related to the fact the data sources are spring managed or if the direct error is more about something else I may be doing wrong.

I have things all wired in spring using the EclipselinkJpaVendorAdapter and I set all of my persistence.xml properties in the spring context through that adapter as follows:

 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
        destroy-method="close"
        p:driverClassName="org.hsqldb.jdbcDriver"
        p:url="">
        p:username="sa"/>

  <bean id="nevadaDataSource" class="org.apache.commons.dbcp.BasicDataSource"
        destroy-method="close"
        p:driverClassName="org.hsqldb.jdbcDriver"
        p:url="">
        p:username="sa"/>

  <bean name="eclipseLinkPersistenceProvider"
        class="org.eclipse.persistence.jpa.PersistenceProvider">
  </bean>

  <bean id="pum"
        class="com.betfair.myproject.spring.extension.MergingPersistenceUnitManager">
    <property name="persistenceXmlLocations">
      <list>
        <value>classpath*:META-INF/persistence.xml</value>
      </list>
    </property>
    <property name="defaultDataSource" ref="dataSource"/>
  </bean>

  <bean id="entityManagerFactory"
          class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
      <property name="persistenceUnitName" value="sample"/>
      <property name="dataSource" ref="dataSource"/>
      <property name="persistenceUnitManager" ref="pum"/>
      <property name="persistenceProvider" ref="eclipseLinkPersistenceProvider"/>
      <property name="jpaVendorAdapter">
        <bean
            class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
          <property name="databasePlatform"
                    value="org.eclipse.persistence.platform.database.HSQLPlatform"/>
          <property name="showSql" value="true"/>
          <property name="generateDdl" value="true"/>
        </bean>
      </property>
          <property name="jpaPropertyMap">
                <map>
                  <entry key="eclipselink.logging.level" value="FINE"/>
                  <entry key="eclipselink.connection-pool.default.nonJtaDataSource" value="dataSource"/>
                  <entry key="eclipselink.connection-pool.nevada.nonJtaDataSource" value="nevadaDataSource"/>
                  <entry key="eclipselink.partitioning" value="Replicate"/>
                </map>
              </property>

    </bean>

I have my classes defined as normal in the persistence.xml as appropriate.  One class I have setup with RoundRobinPartitioning.  When I run a unit test I get the following exception from Eclipselink:

Caused by: Exception [EclipseLink-220] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: Missing partitioning policy for name [Replicate].
at org.eclipse.persistence.exceptions.DescriptorException.missingPartitioningPolicy(DescriptorException.java:2051)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.updatePartitioning(EntityManagerSetupImpl.java:683)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.updateSession(EntityManagerSetupImpl.java:1949)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:471)
... 88 more

Again this is not pointing directly to the fact I am using spring managed data sources, but I am starting to suspect that is actually the issue.

Any assistance is greatly appreciated.

Back to the top