List of usage examples for org.hibernate FlushMode MANUAL
FlushMode MANUAL
To view the source code for org.hibernate FlushMode MANUAL.
Click Source Link
From source file:org.unitime.colleague.model.ColleagueSection.java
License:Apache License
@SuppressWarnings("unchecked") public static List<ColleagueSection> findNotDeletedColleagueSectionsForInstrOfferingConfig( InstrOfferingConfig instrOfferingConfig, Session hibSession) { return ((List<ColleagueSection>) hibSession.createQuery( "select distinct csc.colleagueSection from ColleagueSectionToClass as csc, Class_ c where csc.colleagueSection.deleted = false and c.schedulingSubpart.instrOfferingConfig.uniqueId = :configId and csc.classId = c.uniqueId") .setLong("configId", instrOfferingConfig.getUniqueId().longValue()).setFlushMode(FlushMode.MANUAL) .list());/*from w ww.ja v a 2s. c om*/ }
From source file:org.unitime.colleague.model.ColleagueSection.java
License:Apache License
@SuppressWarnings("unchecked") public static List<ColleagueSection> findColleagueSectionsForSchedulingSubpart( SchedulingSubpart schedulingSubpart, Session hibSession) { return ((List<ColleagueSection>) hibSession.createQuery( "select distinct csc.colleagueSection from ColleagueSectionToClass as csc, Class_ c where c.schedulingSubpart.uniqueId = :subpartId and csc.classId = c.uniqueId") .setLong("subpartId", schedulingSubpart.getUniqueId().longValue()).setFlushMode(FlushMode.MANUAL) .list());//from w w w . j a v a 2s .c om }
From source file:org.unitime.colleague.model.ColleagueSection.java
License:Apache License
@SuppressWarnings("unchecked") public static List<ColleagueSection> findNotDeletedColleagueSectionsForSchedulingSubpart( SchedulingSubpart schedulingSubpart, Session hibSession) { return ((List<ColleagueSection>) hibSession.createQuery( "select distinct csc.colleagueSection from ColleagueSectionToClass as csc, Class_ c where c.schedulingSubpart.uniqueId = :subpartId and csc.classId = c.uniqueId and csc.colleagueSection.deleted = false") .setLong("subpartId", schedulingSubpart.getUniqueId().longValue()).setFlushMode(FlushMode.MANUAL) .list());/*from w w w.j a v a2 s . co m*/ }
From source file:org.unitime.colleague.model.ColleagueSection.java
License:Apache License
@SuppressWarnings("unchecked") public static List<ColleagueSection> findNotDeletedColleagueSectionsForSchedulingSubpartAndCourse( SchedulingSubpart schedulingSubpart, CourseOffering courseOffering, Session hibSession) { return ((List<ColleagueSection>) hibSession.createQuery( "select distinct csc.colleagueSection from ColleagueSectionToClass as csc, Class_ c where c.schedulingSubpart.uniqueId = :subpartId and csc.classId = c.uniqueId and csc.colleagueSection.deleted = false and csc.colleagueSection.courseOfferingId = :courseId") .setLong("subpartId", schedulingSubpart.getUniqueId().longValue()) .setLong("courseId", courseOffering.getUniqueId().longValue()).setFlushMode(FlushMode.MANUAL) .list());/*ww w .j a v a 2 s . co m*/ }
From source file:org.unitime.colleague.model.ColleagueSection.java
License:Apache License
@SuppressWarnings("unchecked") public static List<ColleagueSection> findColleagueSectionsForSolution(Solution solution, Session hibSession) { Vector<ColleagueSection> hs = new Vector<ColleagueSection>(); List<ColleagueSection> sections = hibSession.createQuery( "select distinct csc.colleagueSection from ColleagueSectionToClass as csc, Assignment a where a.solution.uniqueId = :solutionId and csc.classId = a.clazz.uniqueId and csc.colleagueSection.deleted = false") .setLong("solutionId", solution.getUniqueId().longValue()).setFlushMode(FlushMode.MANUAL) .setCacheable(false).list(); for (ColleagueSection cs : sections) { hs.add(cs);// www . j av a 2 s. c o m } return (hs); }
From source file:org.unitime.colleague.model.ColleagueSection.java
License:Apache License
@SuppressWarnings("unchecked") public static void removeOrphanedColleagueSections(Session hibSession) { String orphanedSectionsQuery1 = "select distinct cs from ColleagueSection cs where cs.deleted = false and cs.courseOfferingId not in ( select co.uniqueId from CourseOffering co )"; String orphanedSectionsQuery2 = "select distinct csc.colleagueSection from ColleagueSectionToClass csc where csc.colleagueSection.deleted = false and csc.classId not in ( select c.uniqueId from Class_ c )"; Transaction trans = hibSession.beginTransaction(); List<ColleagueSection> orphanedColleagueSections1 = (List<ColleagueSection>) hibSession .createQuery(orphanedSectionsQuery1).setFlushMode(FlushMode.MANUAL).list(); removeOrphanedColleagueSections(hibSession, orphanedColleagueSections1); List<ColleagueSection> orphanedColleagueSections2 = (List<ColleagueSection>) hibSession .createQuery(orphanedSectionsQuery2).setFlushMode(FlushMode.MANUAL).list(); removeOrphanedColleagueSections(hibSession, orphanedColleagueSections2); trans.commit();/* ww w.j a v a2 s. co m*/ }
From source file:org.unitime.colleague.model.ColleagueSection.java
License:Apache License
public static ColleagueSection findColleagueSectionForClassAndCourseOffering(Class_ clazz, CourseOffering courseOffering, Session hibSession) { if (clazz == null || courseOffering == null) { return (null); }//w ww. j av a 2 s . co m return ((ColleagueSection) hibSession.createQuery( "select distinct csc.colleagueSection from ColleagueSectionToClass as csc where csc.colleagueSection.courseOfferingId = :courseOfferingId " + " and csc.classId = :classId and csc.colleagueSection.deleted = false") .setLong("classId", clazz.getUniqueId().longValue()) .setLong("courseOfferingId", courseOffering.getUniqueId().longValue()) .setFlushMode(FlushMode.MANUAL).setCacheable(false).uniqueResult()); }
From source file:org.unitime.colleague.model.ColleagueSection.java
License:Apache License
public static ColleagueSection findColleagueSectionForClassAndCourseOfferingCacheable(Class_ clazz, CourseOffering courseOffering, Session hibSession) { if (clazz == null || courseOffering == null) { return (null); }/*from w ww . j av a 2 s . com*/ return ((ColleagueSection) hibSession.createQuery( "select distinct csc.colleagueSection from ColleagueSectionToClass as csc where csc.colleagueSection.courseOfferingId = :courseOfferingId " + " and csc.classId = :classId and csc.colleagueSection.deleted = false") .setLong("classId", clazz.getUniqueId().longValue()) .setLong("courseOfferingId", courseOffering.getUniqueId().longValue()) .setFlushMode(FlushMode.MANUAL).setCacheable(true).uniqueResult()); }
From source file:org.unitime.colleague.model.ColleagueSession.java
License:Apache License
public static ColleagueSession findColleagueSessionForSession(Long acadSessionId, org.hibernate.Session hibSession) { if (acadSessionId == null) { return (null); }/* w w w . j a va 2s .c om*/ org.hibernate.Session querySession = hibSession; if (querySession == null) { querySession = ColleagueSessionDAO.getInstance().getSession(); } return ((ColleagueSession) querySession .createQuery("from ColleagueSession cs where cs.session.uniqueId = :sessionId") .setFlushMode(FlushMode.MANUAL).setLong("sessionId", acadSessionId.longValue()).setCacheable(true) .uniqueResult()); }
From source file:org.unitime.timetable.action.ajax.CourseNumSuggestAction.java
License:Open Source License
/** * Retrieve Suggestion List of Course Numbers for a given Subject Area *///w ww .j av a2 s . co m public Collection getMultipleSuggestionList(HttpServletRequest request, Map map) { List result = null; // Read form variables -- Classes Schedule Screen if (map.get("session") != null && map.get("session") instanceof String && map.get("subjectArea") != null && map.get("subjectArea") instanceof String && map.get("courseNumber") != null) { StringBuffer query = new StringBuffer(); query.append("select distinct co.courseNbr "); query.append(" from CourseOffering co "); query.append(" where co.subjectArea.session.uniqueId = :acadSessionId "); query.append(" and co.subjectArea.subjectAreaAbbreviation = :subjectArea"); query.append(" and co.courseNbr like :courseNbr "); query.append(" order by co.courseNbr "); CourseOfferingDAO cdao = new CourseOfferingDAO(); Session hibSession = cdao.getSession(); Query q = hibSession.createQuery(query.toString()); q.setFetchSize(5000); q.setCacheable(true); q.setFlushMode(FlushMode.MANUAL); q.setInteger("acadSessionId", Integer.parseInt(map.get("session").toString())); q.setString("subjectArea", map.get("subjectArea").toString()); q.setString("courseNbr", map.get("courseNumber").toString() + "%"); result = q.list(); if (result == null) result = new ArrayList(); return result; } User user = Web.getUser(request.getSession()); // Security Checks if (!Web.isLoggedIn(request.getSession()) || user == null || user.getAttribute(Constants.SESSION_ID_ATTR_NAME) == null) return new ArrayList(); // Get Academic Session String acadSessionId = user.getAttribute(Constants.SESSION_ID_ATTR_NAME).toString(); // Read form variables -- Instructional Offerings Screen, Reservations Screen if (map.get("subjectAreaId") != null && map.get("courseNbr") != null && map.get("subjectAreaId").toString().length() > 0 && !Constants.ALL_OPTION_VALUE.equals(map.get("subjectAreaId"))) { StringBuffer query = new StringBuffer(); query.append("select distinct co.courseNbr "); query.append(" from CourseOffering co "); query.append(" where co.subjectArea.session.uniqueId = :acadSessionId "); query.append(" and co.subjectArea.uniqueId = :subjectAreaId "); query.append(" and co.courseNbr like :courseNbr "); //query.append(" and co.isControl = true "); query.append(" order by co.courseNbr "); CourseOfferingDAO cdao = new CourseOfferingDAO(); Session hibSession = cdao.getSession(); Query q = hibSession.createQuery(query.toString()); q.setFetchSize(5000); q.setCacheable(true); q.setFlushMode(FlushMode.MANUAL); q.setInteger("acadSessionId", Integer.parseInt(acadSessionId)); q.setInteger("subjectAreaId", Integer.parseInt(map.get("subjectAreaId").toString())); q.setString("courseNbr", map.get("courseNbr").toString() + "%"); result = q.list(); } // Read form variables -- Distribution Preferences Screen if (map.get("filterSubjectAreaId") != null && !Constants.BLANK_OPTION_VALUE.equals(map.get("filterSubjectAreaId")) && !Constants.ALL_OPTION_VALUE.equals(map.get("filterSubjectAreaId")) && map.get("filterCourseNbr") != null) { StringBuffer query = new StringBuffer(); query.append("select distinct co.courseNbr "); query.append(" from CourseOffering co "); query.append(" where co.subjectArea.session.uniqueId = :acadSessionId "); query.append(" and co.subjectArea.uniqueId = :subjectAreaId "); query.append(" and co.courseNbr like :courseNbr "); query.append(" and co.isControl = true "); query.append(" and co.instructionalOffering.notOffered = false "); query.append(" order by co.courseNbr "); CourseOfferingDAO cdao = new CourseOfferingDAO(); Session hibSession = cdao.getSession(); Query q = hibSession.createQuery(query.toString()); q.setFetchSize(5000); q.setCacheable(true); q.setFlushMode(FlushMode.MANUAL); q.setInteger("acadSessionId", Integer.parseInt(acadSessionId)); q.setInteger("subjectAreaId", Integer.parseInt(map.get("filterSubjectAreaId").toString())); q.setString("courseNbr", map.get("filterCourseNbr").toString() + "%"); result = q.list(); } // Read form variables -- Classes Screen if (map.get("subjectAreaIds") != null && map.get("subjectAreaIds") instanceof String && map.get("courseNbr") != null) { StringBuffer query = new StringBuffer(); query.append("select distinct co.courseNbr "); query.append(" from CourseOffering co "); query.append(" where co.subjectArea.session.uniqueId = :acadSessionId "); query.append(" and co.subjectArea.uniqueId = :subjectAreaId"); query.append(" and co.courseNbr like :courseNbr "); query.append(" and co.instructionalOffering.notOffered = false "); //query.append(" and co.isControl = true "); query.append(" order by co.courseNbr "); CourseOfferingDAO cdao = new CourseOfferingDAO(); Session hibSession = cdao.getSession(); Query q = hibSession.createQuery(query.toString()); q.setFetchSize(5000); q.setCacheable(true); q.setFlushMode(FlushMode.MANUAL); q.setInteger("acadSessionId", Integer.parseInt(acadSessionId)); q.setInteger("subjectAreaId", Integer.parseInt(map.get("subjectAreaIds").toString())); q.setString("courseNbr", map.get("courseNbr").toString() + "%"); result = q.list(); } if (result == null) result = new ArrayList(); return result; }