mirror of https://github.com/apache/openjpa.git
OPENJPA-1038: detect circular dependencies among embeddables
and issue proper error message to avoid stack overflow git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@765846 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d9039ca640
commit
1da766bc55
|
@ -1673,8 +1673,7 @@ public class ClassMetaData
|
||||||
|
|
||||||
// are we the target of an embedded value?
|
// are we the target of an embedded value?
|
||||||
if (embed) {
|
if (embed) {
|
||||||
if (_owner.getFieldMetaData().getDefiningMetaData().
|
if (recursiveEmbed(_owner))
|
||||||
getDescribedType().isAssignableFrom(_type))
|
|
||||||
throw new MetaDataException(_loc.get("recurse-embed", _owner));
|
throw new MetaDataException(_loc.get("recurse-embed", _owner));
|
||||||
|
|
||||||
// copy info from the "real" metadata for this type
|
// copy info from the "real" metadata for this type
|
||||||
|
@ -1765,6 +1764,17 @@ public class ClassMetaData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean recursiveEmbed(ValueMetaData owner) {
|
||||||
|
ClassMetaData cm = owner.getFieldMetaData().getDefiningMetaData();
|
||||||
|
if (cm.getDescribedType().isAssignableFrom(_type))
|
||||||
|
return true;
|
||||||
|
ValueMetaData owner1 = cm.getEmbeddingMetaData();
|
||||||
|
if (owner1 == null)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return recursiveEmbed(owner1);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate resolved metadata.
|
* Validate resolved metadata.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue