RuralHouse house = new RuralHouse(rh.getHouseName(), null, null, null,
null);
try {
- ObjectSet<Owner> result = db.queryByExample(house);
+ ObjectSet<RuralHouse> result = db.queryByExample(house);
if (result.isEmpty()) {
- db.store(rh);
+ Owner ow = (Owner) db.queryByExample(rh.getOwner()).get(0);
+ db.delete(ow);
+ ow.addRuralHouse(rh);
+ db.store(ow);
db.commit();
stored = true;
} else {
if (!rhs.isEmpty()) {
Owner found = result.get(0);
found.getRuralHouses().remove(rhs.get(0));
+ db.delete(rhs.get(0));
db.store(found);
db.commit();
}