You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Fabio Martelli <fa...@gmail.com> on 2012/12/15 10:47:40 UTC

Configuring datasources working with Slice and Spring

Hi All,
I'm working with Slice and Spring. 
I'd like to specify a different datasource per slice.

In particular, I'd like to have:
1. Spring datasource as <jta-data-source>  (connected to the distributed/virtual connection)
2. a different external (provided by the web container) datasource for each slice (including the master)

I tried following  https://issues.apache.org/jira/browse/OPENJPA-1643 without any success.

My current relevant configuration is the following.

Spring persistence context:
  ...
  <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="java:comp/env/jdbc/syncopeDataSource"/>
    <property name="defaultObject" ref="localDataSource"/>
  </bean>
  
  <bean id="localDataSource" class="org.springframework.jdbc.datasource.IsolationLevelDataSourceAdapter">
    <property name="targetDataSource">
      <bean class="org.springframework.jdbc.datasource.DriverManagerDataSource">
	<property name="driverClassName" value="${jpa.driverClassName}"/>
	<property name="url" value="${jpa.url}"/>
	<property name="username" value="${jpa.username}"/>
	<property name="password" value="${jpa.password}"/>
      </bean>
    </property>
    <property name="isolationLevelName" value="ISOLATION_READ_COMMITTED"/>
  </bean>
  ...
  <property name="jpaPropertyMap">
      <map>
        <entry key="openjpa.slice.ROOT.ConnectionFactoryName" value="jdbc/root"/>
        <entry key="openjpa.slice.UsersFed.0.ConnectionFactoryName" value="jdbc/userfed0"/>
        <entry key="openjpa.slice.UsersFed.1.ConnectionFactoryName" value="jdbc/userfed1"/>
        <entry key="openjpa.slice.UsersFed.2.ConnectionFactoryName" value="jdbc/userfed2"/>
        <entry key="openjpa.slice.UsersFed.3.ConnectionFactoryName" value="jdbc/userfed3"/>
        <entry key="openjpa.slice.UsersFed.4.ConnectionFactoryName" value="jdbc/userfed4"/>
        ....
        </map>
  </property>
  ...

Please, can someone help me with this issue?

Thank you in advance.
Best regards,
F.



Re: Configuring datasources working with Slice and Spring

Posted by Fabio Martelli <fa...@gmail.com>.
Il giorno 15/dic/2012, alle ore 10.47, Fabio Martelli ha scritto:

> Hi All,
> I'm working with Slice and Spring. 
> I'd like to specify a different datasource per slice.
> 
> In particular, I'd like to have:
> 1. Spring datasource as <jta-data-source>  (connected to the distributed/virtual connection)
> 2. a different external (provided by the web container) datasource for each slice (including the master)

Hi All,
I found the problem: I removed the spring datasource declaration and, now, the following configuration is working fine.

Regards,
F.

> 
> I tried following  https://issues.apache.org/jira/browse/OPENJPA-1643 without any success.
> 
> My current relevant configuration is the following.
> 
> Spring persistence context:
>   ...
>   <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
>     <property name="jndiName" value="java:comp/env/jdbc/syncopeDataSource"/>
>     <property name="defaultObject" ref="localDataSource"/>
>   </bean>
>   
>   <bean id="localDataSource" class="org.springframework.jdbc.datasource.IsolationLevelDataSourceAdapter">
>     <property name="targetDataSource">
>       <bean class="org.springframework.jdbc.datasource.DriverManagerDataSource">
> 	<property name="driverClassName" value="${jpa.driverClassName}"/>
> 	<property name="url" value="${jpa.url}"/>
> 	<property name="username" value="${jpa.username}"/>
> 	<property name="password" value="${jpa.password}"/>
>       </bean>
>     </property>
>     <property name="isolationLevelName" value="ISOLATION_READ_COMMITTED"/>
>   </bean>
>   ...
>   <property name="jpaPropertyMap">
>       <map>
>         <entry key="openjpa.slice.ROOT.ConnectionFactoryName" value="jdbc/root"/>
>         <entry key="openjpa.slice.UsersFed.0.ConnectionFactoryName" value="jdbc/userfed0"/>
>         <entry key="openjpa.slice.UsersFed.1.ConnectionFactoryName" value="jdbc/userfed1"/>
>         <entry key="openjpa.slice.UsersFed.2.ConnectionFactoryName" value="jdbc/userfed2"/>
>         <entry key="openjpa.slice.UsersFed.3.ConnectionFactoryName" value="jdbc/userfed3"/>
>         <entry key="openjpa.slice.UsersFed.4.ConnectionFactoryName" value="jdbc/userfed4"/>
>         ....
>         </map>
>   </property>
>   ...
> 
> Please, can someone help me with this issue?
> 
> Thank you in advance.
> Best regards,
> F.
> 
>