boolean result = false;
ISuportePersistente sp = PersistenceSupportFactory.getDefaultPersistenceSupport();
    public Object run(Integer examOID) throws FenixServiceException {        boolean result = false;        try {            ISuportePersistente sp = PersistenceSupportFactory.getDefaultPersistenceSupport();            IExam examToDelete = (IExam) sp.getIPersistentExam().readByOID(Exam.class, examOID);            if (examToDelete == null) {                throw new FenixServiceException("The exam does not exist");            }            IPersistentExamStudentRoom persistentExamStudentRoom = sp.getIPersistentExamStudentRoom();            List examStudentRoomList = persistentExamStudentRoom.readByExamOID(examToDelete                    .getIdInternal());            if (examStudentRoomList != null && examStudentRoomList.size() > 0) {                throw new notAuthorizedServiceDeleteException(                        "error.notAuthorizedExamDelete.withStudent");            }            List roomOccupations = examToDelete.getAssociatedRoomOccupation();            if (roomOccupations != null && !roomOccupations.isEmpty()) {                Iterator iter = roomOccupations.iterator();                IPeriod period = null;                if (!examToDelete.getAssociatedRoomOccupation().isEmpty()) {                    period = ((IRoomOccupation) roomOccupations.get(0)).getPeriod();                }                boolean isEmpty = false;                List periodRoomOccupations = period.getRoomOccupations();                Collection otherRoomOccupations = CollectionUtils.disjunction(roomOccupations,                        periodRoomOccupations);                isEmpty = otherRoomOccupations.isEmpty();                while (iter.hasNext()) {                    IRoomOccupation roomOccupation = (IRoomOccupation) iter.next();                    roomOccupation.getPeriod().getRoomOccupations().remove(roomOccupation);                    roomOccupation.getWrittenEvaluation().getAssociatedRoomOccupation().remove(                            roomOccupation);                    // roomOccupation.getLesson().setRoomOccupation(null);                    roomOccupation.getRoom().getRoomOccupations().remove(roomOccupation);                    roomOccupation.setPeriod(null);                    roomOccupation.setWrittenEvaluation(null);                    // roomOccupation.setLesson(null);                    roomOccupation.setRoom(null);                    sp.getIPersistentRoomOccupation().deleteByOID(RoomOccupation.class,                            roomOccupation.getIdInternal());                    // sp.getIPersistentRoomOccupation().delete(roomOccupation);                }                if (period != null) {                    if (isEmpty && period.getExecutionDegreesForExamsFirstSemester().isEmpty()                            && period.getExecutionDegreesForExamsSecondSemester().isEmpty()                            && period.getExecutionDegreesForLessonsFirstSemester().isEmpty()                            && period.getExecutionDegreesForLessonsSecondSemester().isEmpty()) {                        // sp.getIPersistentPeriod().delete(period);                        sp.getIPersistentPeriod().deleteByOID(Period.class, period.getIdInternal());                    }                }            }            new DeleteExam().run(examOID);            result = true;        } catch (ExcepcaoPersistencia ex) {            throw new FenixServiceException("Error deleting exam");        }        return new Boolean(result);    }