users@glassfish.java.net

Re: Simple JPA demo for Java SE

From: <glassfish_at_javadesktop.org>
Date: Fri, 23 Feb 2007 22:41:56 PST

Both. I modified the example to persist more than one Person object in a single invocation. That works and each Person gets a unique database Id. But the database Id is not populated back into the newly persisted object which still has a null Id in memory.

So if I add @GeneratedValue(strategy=GenerationType.IDENTITY) as you correctly suggested the newly persisted Person has the new database Id when the entity is flushed.

The example Person primary key should have @GeneratedValue(strategy=GenerationType.IDENTITY)
[Message sent by forum member 'jotobjects' (jotobjects)]

http://forums.java.net/jive/thread.jspa?messageID=205086