users@glassfish.java.net

Re: Two EJB modules inside one EAR and entity manager

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Wed, 10 Oct 2007 16:31:54 -0700

Witold Szczerba wrote:
> 2007/10/10, Marina Vatkina <Marina.Vatkina_at_sun.com>:
>
>>Hi Witold,
>>
>>You do need to put your entities into a separate jar into ear's lib/ directory.
>
>
> That is what I really wanted to avoid, because using separate jar for
> entities is not so comfortable :/
> If I would do that - where am I suppose to place persistence.xml file?

Into entities.jar

> Inside that jar, so it would be available for all EJB modules or each
> module has to declare its own persistence.xml and specify every entity
> class - one by one inside its own PU?

No, by that they'll share the same PU.

>
>
>>By having them inside a module, you limit their scope/visibility to that module
>>only. A global PU means that it's shared, not duplicated, and if you inject an
>>EM in your EJBs, the beans participating in the same transaction will share the
>>same persistence context.
>
>
> This is really strange to me. Session beans are inside EJB module and
> you can call them from everywhere... I can't see why this is not the
> case with entity manager.

It's the scoping rules of PUs. Did you read 6.2.2 Persistence Unit Scope of the
JPA spec?

HTH,
-marina

>
>
>>-marina
>
> Thanks,
> Witold Szczerba
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>