Thanks for the doc-link and the explanation.

I did actually use the <class> elements eventually, and it did the trick.

Quintin Beukes



On Wed, Sep 23, 2009 at 12:19 PM, David Blevins <[email protected]> wrote:
>
> On Sep 21, 2009, at 2:59 AM, Quintin Beukes wrote:
>
>> Hey,
>>
>> I have 2 persistence units, one for each module in the system. The
>> first has an entity Employee, and the other has an Entity
>> LampAssignment. LampAssignment has a @OneToOne on a field:
>> private Employee employee;
>>
>> The JAR containing Employee is KMS-Personnel-ejb-1.0.jar, and it's PU
>> is: KMS-Personnel-PU
>> The JAR containing LampAssignment is VDS-lamps-ejb, and it's PU is:
>> VDS-lamps-PU
>>
>> When I try and run this OpenEJB give the following output:
>
> [...]
>>
>> ERROR - Application could not be deployed:  classpath.ear
>> org.apache.openejb.OpenEJBException: Creating application failed:
>> classpath.ear: org.hibernate.AnnotationException: @OneToOne or
>> @ManyToOne on net.kunye.vds.lamps.LampAssignment.employee references
>> an unknown entity: net.kunye.personnel.Employee: @OneToOne or
>> @ManyToOne on net.kunye.vds.lamps.LampAssignment.employee references
>> an unknown entity: net.kunye.personnel.Employee
>
> [...]
>>
>> How can I get them to notice each other?
>
> No real way to split them into two units like that.  A persistence-unit is
> really the definition of a database cache.  Meaning it's a whole view of an
> entire set of data.  The entity manager instance is really your way to pull
> and push data to and from that cache and by definition it can't see data for
> tables (entities) it doesn't control.
>
> A lot of people want to split up their "units" for build reasons and have
> the entities divided into specific jar files, which is more than valid.  But
> at run time it has to be joined together and defined as one persistence-unit
> if the entities are part of the same relational scheme.  You can use the
> persistence.xml <jar-file> element to pull in other jars or use the <class>
> element to list the classes individually and have them count as being in the
> same unit regardless of which jar they may be in.
>
> This doc isn't directly related to your question, but I do find it
> demystifies JPA a bit:
>
>  http://openejb.apache.org/3.0/jpa-concepts.html
>
>
> -David
>
>

Reply via email to