users@glassfish.java.net

Re: How to use JPA's EntityManager.persist() in a servlet - mine does not

From: <glassfish_at_javadesktop.org>
Date: Wed, 20 Feb 2008 10:39:55 PST

OK, the problem is that the entity class, which was generated from the existing derby database using NetBeans, did not have the correct annotation for a generated primary key: that is

SQL column definition:
id int not null generated always as primary key

should result in:

@ID
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name='ID',nullable=false)
private Integer id;

but NetBeans left out the @GeneratedValue annotation

Thank you, everyone
[Message sent by forum member 'bclyon' (bclyon)]

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