Java Code Examples for org.hibernate.Query.iterate()

The following are Jave code examples for showing how to use iterate() of the org.hibernate.Query class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: unitimes   File: TimetableDatabaseLoader.java   View Source Code Vote up 6 votes
private void loadInstructorAvailabilities(org.hibernate.Session hibSession, String puids) {
  	Query q = hibSession.createQuery("select distinct i.externalUniqueId, a from ClassInstructor ci inner join ci.instructor i inner join ci.classInstructing.assignments a " +
  			"where ci.lead = true and i.externalUniqueId in ("+puids+") and a.solution.owner.session.uniqueId=:sessionId and a.solution.commited=true and a.solution.owner.uniqueId not in ("+iSolverGroupIds+")");
  	q.setLong("sessionId",iSessionId.longValue());
for (Iterator i=q.iterate();i.hasNext();) {
	Object[] x = (Object[])i.next();
	String puid = (String)x[0];
	Assignment a = (Assignment)x[1];
	InstructorConstraint ic = (InstructorConstraint)iInstructors.get(puid);
	Placement p = a.getPlacement();
	ic.setNotAvailable(p);
	if (!iLectures.containsKey(a.getClassId())) {
		iLectures.put(a.getClassId(), p.variable());
		getModel().addVariable(p.variable());
	}
	
}
  }
 
Example 2
Project: unitimes   File: TimetableDatabaseLoader.java   View Source Code Vote up 6 votes
private void loadRoomAvailabilities(org.hibernate.Session hibSession, String roomids) {
Query q = hibSession.createQuery("select distinct r.uniqueId, a from Location r inner join r.assignments as a "+
		"where r.uniqueId in ("+roomids+") and a.solution.owner.session.uniqueId=:sessionId and a.solution.commited=true and a.solution.owner.uniqueId not in ("+iSolverGroupIds+") and r.ignoreRoomCheck = false");
q.setLong("sessionId",iSessionId.longValue());
for (Iterator i=q.iterate();i.hasNext();) {
	Object[] x = (Object[])i.next();
	Long roomId = (Long)x[0];
	Assignment a = (Assignment)x[1];
	Placement p = a.getPlacement();
	RoomConstraint rc = (RoomConstraint)iRooms.get(roomId);
	rc.setNotAvailable(p);
	if (!iLectures.containsKey(a.getClassId())) {
		iLectures.put(a.getClassId(), p.variable());
		getModel().addVariable(p.variable());
	}
}
  }