[jboss-user] [EJB 3.0] - Re: One PersistenceUnit, multiple DataSources

7rond do-not-reply at jboss.com
Wed Feb 21 06:47:01 EST 2007


So, I think I figured out a solution that works for me.

In my persistence.xml in my original application EAR, I removed the jar-references and instead added this;

  | <mapping-file>persistence-mapping-file.xml</mapping-file>
  | 

Then, in the persistence.jar within the EAR, I added the persistence-mapping-file.xml containing this;

  | <?xml version="1.0" encoding="UTF-8" ?>
  | <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
  | 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  | 	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
  | 	version="1.0">
  |     
  | 	<package>myproject.entities</package>
  |     
  |     <entity class="myproject.entities.FooEntity" name="FooEntity" />
  |     <entity class="myproject.entities.BarEntity" name="BarEntity" />
  |     
  | </entity-mappings>
  | 

Then I just refer to the same file within the persistence.xmls I deploy in my webapp-EARs and that works more or less as I want.

Does seem like a bit non-standard use of the mapping-file from what I could gather from reading some forums and stuff - but hey, it works. And it's good enough.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4019868#4019868

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4019868



More information about the jboss-user mailing list