Code example for SessionFactory

Methods: getCurrentSession

0
	 
	/** 
	 * @see org.openmrs.api.db.CohortDAO#getCohort(java.lang.Integer) 
	 */ 
	public Cohort getCohort(Integer id) throws DAOException {
		return (Cohort) sessionFactory.getCurrentSession().get(Cohort.class, id);
	} 
	 
	/** 
	 * @see org.openmrs.api.db.CohortDAO#getCohortsContainingPatientId(java.lang.Integer) 
	 */ 
	@SuppressWarnings("unchecked") 
	public List<Cohort> getCohortsContainingPatientId(Integer patientId) throws DAOException {
		Query query = sessionFactory.getCurrentSession().createQuery(
		    "from Cohort c where :patientId in elements(c.memberIds) and c.voided = false order by name"); 
		query.setInteger("patientId", patientId);
		return (List<Cohort>) query.list();
	} 
	 
	/** 
Contextual code suggestions in your IDE  Get Codota for Java