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:
A. Abram White 2007-02-27 18:14:45 +00:00
parent 5ae6e7594f
commit 4bf637f074
6 changed files with 10 additions and 4 deletions

View File

@ -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));

View File

@ -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);

View File

@ -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));

View File

@ -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.

View File

@ -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;
}

View File

@ -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;
}