dataAccessObject.beginTransaction();
for (MultitenancyPackage multitenancyPackage : multitenancyPackages) {
// check the package existence in the database; If not available, insert it
int itemId = dataAccessObject.getItemIdWithName(multitenancyPackage.getName());
if (itemId == DataAccessObject.INVALID) {
itemId = dataAccessObject.addItem(multitenancyPackage);
}
multitenancyPackage.setId(itemId);
multitenancyPackagesMap.put(itemId, multitenancyPackage);
// and add all the sub items too
for (Item subItem : multitenancyPackage.getChildren()) {