Would you please take a look at my code, I keep getting the following exception when I try to insert a record into the database:
Apr 02, 2014 1:30:53 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [UserEditorServlet] in context with path [/My.Web] threw exception
<openjpa-2.2.2-r422266:1468616 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: error during validation of <unknown>
My table is defined like this:
create table User (
id bigint primary key not null auto_increment,
name varchar(200),
status varchar(30),
createdOn datetime,
modifiedOn datetime,
password varchar(60),
index(status)
) ENGINE=InnoDB;
and my identity field like this:
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
protected Long id = null;
it turns out that if I assign a value to my id my exception changes to this:
Apr 02, 2014 1:37:18 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [UserEditorServlet] in context with path [/My.Web] threw exception
<openjpa-2.2.2-r422266:1468616 fatal user error> org.apache.openjpa.persistence.InvalidStateException: Primary key field net.jaimes.Persistent.id of org.apache.openjpa.enhance.ReflectingPersistenceCapable@194765c4 has non-default value. The instance life cycle is in PNewState state and hence an existing non-default value for the identity field is not permitted. You either need to remove the @GeneratedValue annotation or modify the code to remove the initializer processing.
While debugging, I only have one null variable: Id, which is expected to be created by MySQL.
At the end, I cannot insert a simple record...
Thank you