Transaction tx = null;
List toReturn = new ArrayList();
try {
aSession = getSession();
tx = aSession.beginTransaction();
SbiKpiModelInst sbiKpiModelInst = (SbiKpiModelInst) aSession.load(
SbiKpiModelInst.class, parentId);
SbiKpiModel aModel = (SbiKpiModel) sbiKpiModelInst.getSbiKpiModel();
// Load all Children
if (aModel != null) {
Set modelChildren = aModel.getSbiKpiModels();
// Load all ModelInstance Children
Set modelInstanceChildren = sbiKpiModelInst
.getSbiKpiModelInsts();
// Remove all Children just instantiated
for (Iterator iterator = modelInstanceChildren.iterator(); iterator
.hasNext();) {
SbiKpiModelInst child = (SbiKpiModelInst) iterator.next();
modelChildren.remove(child.getSbiKpiModel());
}
for (Iterator iterator = modelChildren.iterator(); iterator
.hasNext();) {
SbiKpiModel sbiKpiModelCandidate = (SbiKpiModel) iterator
.next();