Labels

Wednesday, October 2, 2013

Null or zero primary key encountered in unit of work clone

Null or zero primary key encountered in unit of work clone [Object@3622086c], primary key [0]. Set descriptors IdValidation or the "eclipselink.id-validation" property.

Ran into this at runtime when running a EJB on Glassfish using JPA Entities.  The problem turned out to be a missing annotation on one of the properties in one of the JPA Entities (@GeneratedValue).

The value in question was the primary key for the table and was auto-generated.

Full corrected code:
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;

No comments:

Post a Comment