Code example for SessionFactory

Methods: getCurrentSession

0
//	Query qry = session.createQuery("from org.openiam.idm.srvc.user.dto.UserAttribute ua where ua.userId = :userId order by ua.name asc"); 
//	qry.setString("userId", userId); 
	 
	public PolicyObjectAssoc findAssociationByLevel(String level, String value) {
		try { 
			Session session = sessionFactory.getCurrentSession();
			Query qry = session.createQuery("from org.openiam.idm.srvc.policy.dto.PolicyObjectAssoc p " +
					" where p.associationLevel = :level and p.associationValue = :value " ); 
			qry.setString("level", level);
			qry.setString("value", value);
			List<PolicyObjectAssoc> results = (List<PolicyObjectAssoc>)qry.list();
 
			if (results == null || results.isEmpty()) {
				log.info("No policyAssociation objects found.");
				return null; 
			}else { 
				log.info("PolicAssoc found. Count=" + results.size());
			} 
			return results.get(0);
		} catch (HibernateException re) {
Contextual code suggestions in your IDE  Get Codota for Java