users@glassfish.java.net

getting null primary key

From: <glassfish_at_javadesktop.org>
Date: Fri, 31 Aug 2007 18:07:26 PDT

hi,

I'm trying to get the primary key after execute the following code, but keep getting a null primary key even though the database is updated correctly.

Country has one-to-many relationship with user

[code]
Country country = (Country)em.find(Country.class, countryid);
user.setCountry(country);
country.getUserinfoCollection().add(user);
em.merge(country);
[/code]

also, if i do
[code]
user.setCountry(new Country(id));
em.persist(user);
[/code]

sometime I got the key, but sometime i got null

I'm using Table generator to generate the key

Thanks for your help

jeff
[Message sent by forum member 'eviljanca' (eviljanca)]

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