users@glassfish.java.net

Re: Glassfish v3 - default persistence unit name

From: Sahoo <Sahoo_at_Sun.COM>
Date: Mon, 28 Sep 2009 08:28:35 +0530

You don't need to specify the unitName in @PersistenceContext if there
is only one PersistenceUnit defined in the scope of the component which
is using @PersistenceContext, otherwise you need to specify it.

Sahoo

glassfish_at_javadesktop.org wrote:
> Hi,
>
> I am trying to create a new app in Glassfish V3 with JSF2, et al. To get access to an entity manager the following code seems to be used by most of the examples.
>
> @PersistenceContext(unitName="abc")
> EntityManager em;
>
> Where the abc persistence unit is defined in a persistence.xml file.
>
> How can I define a default persistent unit to be used so that I can write code like
>
> @PersistenceContext
> EntityManager em;
>
> It's important that I don't hard wire the unitName in the code as some of these a relibraries that will be used by multiple applications.
>
> Once again any help would be much appreciated.
>
> Regards.
> [Message sent by forum member 'arshadm' (arshadm_at_compuvision.co.uk)]
>
> http://forums.java.net/jive/thread.jspa?messageID=365952
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>