mirror of https://github.com/apache/openjpa.git
Improve error checks for mapped-by mappings. Mark deleted instances as
eligible for state restore on rollback so they don't always clear. Always cascade attach to embedded instances. git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@512350 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5ae6e7594f
commit
4bf637f074
|
@ -86,7 +86,7 @@ public class RelationFieldStrategy
|
|||
field.getValueInfo().assertNoSchemaComponents(field, !adapt);
|
||||
mapped.resolve(mapped.MODE_META | mapped.MODE_MAPPING);
|
||||
|
||||
if (!mapped.getDefiningMapping().isMapped())
|
||||
if (!mapped.isMapped() || mapped.isSerialized())
|
||||
throw new MetaDataException(_loc.get("mapped-by-unmapped",
|
||||
field, mapped));
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ public abstract class RelationToManyInverseKeyFieldStrategy
|
|||
boolean criteria = vinfo.getUseClassCriteria();
|
||||
if (mapped != null) {
|
||||
mapped.resolve(mapped.MODE_META | mapped.MODE_MAPPING);
|
||||
if (!(mapped.getStrategy()instanceof RelationFieldStrategy))
|
||||
if (!(mapped.getStrategy() instanceof RelationFieldStrategy))
|
||||
throw new MetaDataException(_loc.get("not-inv-relation",
|
||||
field, mapped));
|
||||
vinfo.assertNoSchemaComponents(elem, !adapt);
|
||||
|
|
|
@ -110,7 +110,7 @@ public abstract class RelationToManyTableFieldStrategy
|
|||
vinfo.assertNoSchemaComponents(elem, !adapt);
|
||||
mapped.resolve(mapped.MODE_META | mapped.MODE_MAPPING);
|
||||
|
||||
if (!mapped.getDefiningMapping().isMapped())
|
||||
if (!mapped.isMapped() || mapped.isSerialized())
|
||||
throw new MetaDataException(_loc.get("mapped-by-unmapped",
|
||||
field, mapped));
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ mapped-inverse-unjoined: Field "{0}" as defined in "{1}" cannot be mapped by \
|
|||
"{2}". You cannot use an inverse foreign key to map a superclass field of \
|
||||
an unjoined subclass.
|
||||
mapped-by-unmapped: Field "{0}" cannot be mapped by "{1}", because the related \
|
||||
type is unmapped.
|
||||
field or type is unmapped.
|
||||
cant-join: Cannot join across "{0}". The related type has unjoined subclasses.
|
||||
cant-inverse: "{0}" is not a valid mapping. Inverse foreign key-based \
|
||||
relations to types with unjoined subclasses are not supported.
|
||||
|
|
|
@ -25,6 +25,10 @@ package org.apache.openjpa.kernel;
|
|||
class PDeletedState
|
||||
extends PCState {
|
||||
|
||||
void initialize(StateManagerImpl context) {
|
||||
context.saveFields(false);
|
||||
}
|
||||
|
||||
PCState flush(StateManagerImpl context) {
|
||||
return PDELETEDFLUSHED;
|
||||
}
|
||||
|
|
|
@ -243,6 +243,8 @@ public class ValueMetaDataImpl
|
|||
if (_owner.getManagement() != FieldMetaData.MANAGE_PERSISTENT
|
||||
|| !isDeclaredTypePC()) // attach acts on declared type
|
||||
return CASCADE_NONE;
|
||||
if (isEmbeddedPC())
|
||||
return CASCADE_IMMEDIATE;
|
||||
return _attach;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue