Spencer Strombotne
unread,Apr 27, 2012, 4:02:23 PM4/27/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to play-fr...@googlegroups.com
I've got a simple JPA entity that has two strings for a database table
that already exists. I've extended the Model class so there should be an
autogenerated unique primary key.
When I try to create a new entity like:
MyObject myObject = new MyObject();
myObject.setString1(string1);
myObject.setString2(string2);
myObject.create();
The resulting insert looks like:
DEBUG ~ insert into MYOBJECT (STRING1, STRING2, id) values (?, ?, ?)
I get the exception:
ERROR ~ ORA-00001: unique constraint violated
The
constraint that's being violated is the primary key. Out of curiosity I
tried setting the myObject.id to something I know for certain is unique
MyObject myObject = new MyObject();
myObject.setString1(string1);
myObject.setString2(string2);
myObject.id = 99999999;
myObject.create();
This is inserted no problem. Can anyone tell me why my entity's id isn't being set to a unique long value?