openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Linskey" <>
Subject RE: Get primary key from persistent bean
Date Mon, 11 Dec 2006 22:08:02 GMT
Note that you should either use the OpenJPAPersistence.cast() call or
cast the return result of EntityManager.getDelegate() to portably
convert an EM reference to an OpenJPAEntityManager. This is because
appservers end up needing to proxy EMs, and the spec does not require
that the proxy implement all the interfaces that the EM implements.

Hint to Geronimo team: it'd be swell if you made your injected proxy
implement all the interfaces that the EM implements. Means you need to
go the dynamic proxy route instead of a static proxy route, though.


Patrick Linskey
BEA Systems, Inc. 

Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it. 

> -----Original Message-----
> From: Dain Sundstrom [] 
> Sent: Monday, December 11, 2006 11:01 AM
> To:
> Subject: Get primary key from persistent bean
> Is there a way to extract the primary key from a persistent bean  
> using a spec JPA API or an API specific to OpenJPA?  I'm thinking of  
> something like this:
>      MyBean bean = new MyBean();
>      entityManager.persist(bean);
>      Object pk = entityManager.getPrimaryKey(bean);
>      MyBean foundBean = entityManager.find(MyBean.class, pk);
>      assertEquals(bean, foundBean);
> -dain

View raw message