users@glassfish.java.net

Re: How to reference entity manager from within an entity?

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Mon, 21 Apr 2008 12:23:12 -0700

It's not expected by the spec to define an em on the entity. You'll need to pass
it to the method, or have it as a transient (Java transient is good enough)
variable that you set yourself.

Regards,
-marina

Markus KARG wrote:
> My JPA entity shall call one of it's NamedQueries. For that reasons, I
> wanted to add the following code to my entity:
>
> @PersistenceContext
> EntityManager em;
>
> But the verifier says, that is not working, since EntityManager is not
> serializable.
>
> So I added to it:
>
> @Transient
>
> But now the verifier says, that is not working, since
> @PersistenceContext must not be used together with @Transient.
>
> What can I do?
> How can my entity call it's own named query?
>
> Thanks
> Markus
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net