OPENJPA-1397: Allow some columns of compound key to be null.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@888417 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Pinaki Poddar 2009-12-08 14:51:44 +00:00
parent 3f3d586c73
commit 8607e0b3b4
1 changed files with 5 additions and 2 deletions

View File

@ -172,6 +172,7 @@ public class ClassMapping
Joinable join; Joinable join;
int pkIdx; int pkIdx;
boolean canReadDiscriminator = true; boolean canReadDiscriminator = true;
boolean isNullPK = true;
for (int i = 0; i < pks.length; i++) { for (int i = 0; i < pks.length; i++) {
// we know that all pk column join mappings use primary key fields, // we know that all pk column join mappings use primary key fields,
// cause this mapping uses the oid as its primary key (we recursed // cause this mapping uses the oid as its primary key (we recursed
@ -186,10 +187,12 @@ public class ClassMapping
vals[pkIdx] = join.getPrimaryKeyValue(res, join.getColumns(), vals[pkIdx] = join.getPrimaryKeyValue(res, join.getColumns(),
fk, store, joins); fk, store, joins);
res.endDataRequest(); res.endDataRequest();
if (vals[pkIdx] == null) isNullPK = isNullPK && vals[pkIdx] == null;
return null;
} }
} }
if (isNullPK) {
return null;
}
// the oid data is loaded by the base type, but if discriminator data // the oid data is loaded by the base type, but if discriminator data
// is present, make sure to use it to construct the actual oid instance // is present, make sure to use it to construct the actual oid instance