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.
Thanks a lot.
--
Riccardo Cohen
+33 (0)6 09 83 64 49
Société Realty-Property.com
16 rue de Belle Isle
37100 Tours
France
<http://www.appartement-maison.fr>
_______________________________________________
resin-interest mailing list
[email protected]
http://maillist.caucho.com/mailman/listinfo/resin-interest