Hi Tore,
I suspect that this is a duplicate of CAY-811:
https://issues.apache.org/cayenne/browse/CAY-811
Essentially any user provided value (not just zero) of a meaningful
PK is ignored if the PK is configured as DB-generated.
Andrus
On Jul 30, 2007, at 10:38 AM, Tore Halset (JIRA) wrote:
setting meaningful pk to zero turn on autogenerated keys
--------------------------------------------------------
Key: CAY-835
URL: https://issues.apache.org/cayenne/browse/CAY-835
Project: Cayenne
Issue Type: Bug
Components: Cayenne Core Library
Affects Versions: 3.0
Environment: 3.0M1, derby, mac, java 5
Reporter: Tore Halset
Assignee: Tore Halset
Fix For: 3.0
Having a table with a int primary key mapped to a Integer. Setting
this value to Integer.valueOf(0) makes cayenne create its own
primary key. So instead of value zero, the primary key will be 200
or whatever.
Here is a test that shows this behaviour:
public void testInsertWithMeaningfulPKValueZero() throws
Exception {
Integer zero = new Integer(0);
MeaningfulPKTest1 obj = (MeaningfulPKTest1) context
.newObject("MeaningfulPKTest1");
obj.setPkAttribute(zero);
obj.setDescr("aaa-aaa-bbb");
context.commitChanges();
assertEquals(zero, obj.getPkAttribute());
ObjectIdQuery q = new ObjectIdQuery(new ObjectId(
"MeaningfulPKTest1",
MeaningfulPKTest1.PK_ATTRIBUTE_PK_COLUMN,
zero.intValue()), true, ObjectIdQuery.CACHE_REFRESH);
assertEquals(1, context.performQuery(q).size());
}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.