users@glassfish.java.net

Re: name, mappedName, unitName... getting confused

From: Wouter van Reeven <wouter_at_van.reeven.nl>
Date: Wed, 15 Nov 2006 18:10:38 +0100

Hi Antonio,

On Wed, Nov 15, 2006 at 05:39:34PM +0100, Antonio Goncalves wrote:
> The first one is @Stateless (or @Stateful). What is the name attribute used
> for ? In the specification it says that it's the name of the EJB. But on the
> other hand, when I change it nothing happens but when I use the mappedName
> attribute (which is vendor specific), it really changes the name of my EJB
> in the JNDI tree. For example :

Stateful or Stateless indicates the way the SessionBean is managed by the
EntityManager. In shirt, Stateless beans are kept in a pool and don't hold any
values (also named state, hence the name), while Stateful beans DO contain state
and can be used to e.g. put on a HttpSession to contain session specific values.

> The other one is @PersistenceContext. The name attribute doesn't lead me
> anywhere (I can't see any difference in using it or not) ant the other is
> unitName that has to be equal to the persitent unit name within the
> persistence.xml file. The spec doesn't talk about any vendor specific
> attribute but I don't understand what the name attribute can be used for.

PersistenceContext is the context in which the Persistence Unit resides on the
Enterprise Server. You can use it to inject an EntityManager instance so you can
access EJB instances from your classes.


HTH, Wouter van Reeven

-- 
People: "If she weighs the same as a Duck, she's made of wood!"
Sir Bedevere: "And therefore...?"