/** * Sets the new org type on this group, updating collections in the old and new org type objects * if they're not null * * @param newOrgType * @param session */ public void setRegoOrgType(OrgType newOrgType, Session session) { OrgType oldOrgType = getRegoOrgType(); if (oldOrgType != null) { oldOrgType.getGroups().remove(this); session.save(oldOrgType); } setRegoOrgType(newOrgType); if (newOrgType != null) { if (newOrgType.getGroups() == null) { newOrgType.setGroups(new ArrayList<Group>()); } newOrgType.getGroups().add(this); } }