On 1/3/14, 5:15 AM, Riccardo Cohen wrote:
> Hello
> I will soon have more than one mysql server. I want to use one server
> for read requests of static data, the other for read/write requests of
> dynamic data. It works for sql requests through datasource, but I cannot
> find how to do it with ejb manager.
>
> In my resin.xml I have this :
>
> <database jndi-name="jdbc/adlresintest">
> ...
> </database>
> <ejb-server data-source="jdbc/adlresintest"
> create-database-schema="false"
> jndi-name="ejb"/>
> <database jndi-name="jdbc/adlresintest2">
> ...
> </database>
> <ejb-server data-source="jdbc/adlresintest2"
> create-database-schema="false"
> jndi-name="ejb2"/>
>
> In persistence.xml :
>
> <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
> <persistence-unit name="adlresintestunit">
> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
> <class>adlresintest.Adluser</class>
> <exclude-unlisted-classes />
> <properties>
> <property name="eclipselink.ddl-generation.output-mode"
> value="database" />
> <property name="eclipselink.weaving.fetchgroups" value="false"/>
> </properties>
> </persistence-unit>
> </persistence>
>
> In my java code I have this :
>
> @Inject @Named("jdbc/adlresintest") public DataSource
> m_datasource1;// public site
> @Inject @Named("jdbc/adlresintest2") public DataSource
> m_datasource2;// not used for the moment
> @PersistenceUnit(name="adlresintestunit") @Named("ejb")
> EntityManagerFactory ejbfactory1;
> @PersistenceUnit(name="adlresintestunit") @Named("ejb2")
> EntityManagerFactory ejbfactory2;
>
>
> When using datasource1 or 2 I access the correct database. But when
> using ejbfactory1 or 2, only the second database is accessed. The
> association created with "jndi-name" and @Named() works for
> DataSource/<database> but not for EntityManagerFactory/<ejb-server>.
>
> I also tried to use composite persistence unit as written here :
> http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Composite_Persistence_Units
> but I could not find the good configuration to do it, the tag
> <jta-data-source> was not accepted. I could not find in
> http://eclipse.org/eclipselink/documentation/2.4/jpa/extensions/persistenceproperties_ref.htm
> which property to set for the datasource.
The configuration should be <jta-data-source> and <non-jta-data-source>
in the <persistence-unit>:
<persistence ...>
<persistence-unit name="test" ...>
<jta-data-source>jdbc/adlresintest</jta-data-source>
...
</persistence-unit>
<persistence-unit name="test2" ...>
<jta-data-source>jdbc/adlresintest2</jta-data-source>
...
Since the jta-data-source tag is part of the JPA spec, it should be
recognized by eclipse-link.
-- Scott
>
> Thanks a lot.
>
_______________________________________________
resin-interest mailing list
[email protected]
http://maillist.caucho.com/mailman/listinfo/resin-interest