users@glassfish.java.net

Re: Two EJB modules inside one EAR and entity manager

From: Witold Szczerba <pljosh.mail_at_gmail.com>
Date: Thu, 11 Oct 2007 01:19:56 +0200

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?
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?

> 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.

> -marina
Thanks,
Witold Szczerba