openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig L Russell <Craig.Russ...@Sun.COM>
Subject Re: Get primary key from persistent bean
Date Tue, 12 Dec 2006 01:34:39 GMT
Hi Dain,

How about

Object pk = bean.getId();

Craig

On Dec 11, 2006, at 11:00 AM, Dain Sundstrom wrote:

> 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

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Mime
View raw message