* Throw explicit exceptions when a derived property is set to the id of a
transient object. Fixed bug 607. <http://helma.org/bugs/show_bug.cgi?id=607>
This commit is contained in:
parent
b0723569b2
commit
3526050006
1 changed files with 8 additions and 2 deletions
|
@ -1159,9 +1159,12 @@ public final class Relation {
|
||||||
if (foreignIsPrimary || cnst.foreignKeyIsPrototype()) {
|
if (foreignIsPrimary || cnst.foreignKeyIsPrototype()) {
|
||||||
String localProp = cnst.localProperty();
|
String localProp = cnst.localProperty();
|
||||||
if (localProp == null) {
|
if (localProp == null) {
|
||||||
ownType.app.logError("Error: column " + cnst.localKey +
|
throw new RuntimeException("Error: column " + cnst.localKey +
|
||||||
" must be mapped in order to be used as constraint in " +
|
" must be mapped in order to be used as constraint in " +
|
||||||
Relation.this);
|
Relation.this);
|
||||||
|
} else if (foreignIsPrimary && child.getState() == Node.TRANSIENT) {
|
||||||
|
throw new RuntimeException(propName + " set to transient object, " +
|
||||||
|
"can't derive persistent ID for " + localProp);
|
||||||
} else {
|
} else {
|
||||||
String value = foreignIsPrimary ?
|
String value = foreignIsPrimary ?
|
||||||
child.getID() : child.getDbMapping().getStorageTypeName();
|
child.getID() : child.getDbMapping().getStorageTypeName();
|
||||||
|
@ -1198,6 +1201,9 @@ public final class Relation {
|
||||||
// correctly for transient nodes, so this may fail.
|
// correctly for transient nodes, so this may fail.
|
||||||
}
|
}
|
||||||
} else if (crel.reftype == PRIMITIVE) {
|
} else if (crel.reftype == PRIMITIVE) {
|
||||||
|
if (home.getState() == Node.TRANSIENT) {
|
||||||
|
throw new RuntimeException("Object is transient, can't derive persistent ID for " + crel);
|
||||||
|
}
|
||||||
child.setString(crel.propName, home.getID());
|
child.setString(crel.propName, home.getID());
|
||||||
}
|
}
|
||||||
} else if (crel.reftype == PRIMITIVE) {
|
} else if (crel.reftype == PRIMITIVE) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue