mirror of https://github.com/apache/openjpa.git
OPENJPA-1438: fix wherePrimaryKey for entity using derived identity
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@892430 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5d9f08e728
commit
d189eac9dd
|
@ -183,7 +183,8 @@ public class RowImpl
|
||||||
while (mapping.getTable() != getTable())
|
while (mapping.getTable() != getTable())
|
||||||
mapping = mapping.getPCSuperclassMapping();
|
mapping = mapping.getPCSuperclassMapping();
|
||||||
Column[] cols = mapping.getPrimaryKeyColumns();
|
Column[] cols = mapping.getPrimaryKeyColumns();
|
||||||
flushJoinValues(sm, cols, cols, io, set);
|
Object oid = mapping.useIdClassFromParent() ? sm.getObjectId() : null;
|
||||||
|
flushJoinValues(sm, oid, cols, cols, io, set);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setForeignKey(ForeignKey fk, OpenJPAStateManager sm)
|
public void setForeignKey(ForeignKey fk, OpenJPAStateManager sm)
|
||||||
|
@ -219,7 +220,7 @@ public class RowImpl
|
||||||
private void flushForeignKey(ForeignKey fk, ColumnIO io,
|
private void flushForeignKey(ForeignKey fk, ColumnIO io,
|
||||||
OpenJPAStateManager sm, boolean set)
|
OpenJPAStateManager sm, boolean set)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
flushJoinValues(sm, fk.getPrimaryKeyColumns(), fk.getColumns(),
|
flushJoinValues(sm, null, fk.getPrimaryKeyColumns(), fk.getColumns(),
|
||||||
io, set);
|
io, set);
|
||||||
if (sm != null) {
|
if (sm != null) {
|
||||||
Column[] cols = fk.getConstantColumns();
|
Column[] cols = fk.getConstantColumns();
|
||||||
|
@ -250,7 +251,7 @@ public class RowImpl
|
||||||
* @param set whether this should be flushed as an update or
|
* @param set whether this should be flushed as an update or
|
||||||
* as a where condition
|
* as a where condition
|
||||||
*/
|
*/
|
||||||
private void flushJoinValues(OpenJPAStateManager to, Column[] toCols,
|
private void flushJoinValues(OpenJPAStateManager to, Object oid, Column[] toCols,
|
||||||
Column[] fromCols, ColumnIO io, boolean set)
|
Column[] fromCols, ColumnIO io, boolean set)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
if (to == null) {
|
if (to == null) {
|
||||||
|
@ -278,8 +279,13 @@ public class RowImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
join = toMapping.assertJoinable(toCols[i]);
|
join = toMapping.assertJoinable(toCols[i]);
|
||||||
|
if (oid != null)
|
||||||
|
val = join.getJoinValue(oid, toCols[i], (JDBCStore) to.
|
||||||
|
getContext().getStoreManager().getInnermostDelegate());
|
||||||
|
else
|
||||||
val = join.getJoinValue(to, toCols[i], (JDBCStore) to.
|
val = join.getJoinValue(to, toCols[i], (JDBCStore) to.
|
||||||
getContext().getStoreManager().getInnermostDelegate());
|
getContext().getStoreManager().getInnermostDelegate());
|
||||||
|
|
||||||
if (set && val == null) {
|
if (set && val == null) {
|
||||||
if (canSet(io, i, true))
|
if (canSet(io, i, true))
|
||||||
setNull(fromCols[i]);
|
setNull(fromCols[i]);
|
||||||
|
|
|
@ -610,6 +610,10 @@ public class TestMappedById extends SingleEMFTestCase {
|
||||||
MedicalHistory3 m = em.find(MedicalHistory3.class, new PersonId3("f_1", "l_1"));
|
MedicalHistory3 m = em.find(MedicalHistory3.class, new PersonId3("f_1", "l_1"));
|
||||||
MedicalHistory3 m0 = medicals3.get("f_1");
|
MedicalHistory3 m0 = medicals3.get("f_1");
|
||||||
assertEquals(m, m0);
|
assertEquals(m, m0);
|
||||||
|
|
||||||
|
em.getTransaction().begin();
|
||||||
|
em.remove(m);
|
||||||
|
em.getTransaction().commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void queryObj6() {
|
public void queryObj6() {
|
||||||
|
|
Loading…
Reference in New Issue