Code example for SessionFactory

Methods: getCurrentSession

0
    	List<SupervisorEntity> results = (List<SupervisorEntity>)criteria.list();
    	return results;    	
    } 
     
    public SupervisorEntity findPrimarySupervisor(String employeeId) {
    	Session session = sessionFactory.getCurrentSession();
    	Criteria criteria = session.createCriteria(SupervisorEntity.class)
                .add(Restrictions.eq("employee.userId",employeeId))
                .add(Restrictions.eq("isPrimarySuper",1))
                .addOrder(Order.asc("supervisor.userId"));
 
    	SupervisorEntity supr = (SupervisorEntity)criteria.uniqueResult();
    	if (supr == null)
    		return null; 
 
    	org.hibernate.Hibernate.initialize(supr.getSupervisor());
    	org.hibernate.Hibernate.initialize(supr.getEmployee());
   	 
    	return supr;
    	//List<Supervisor> results = (List<Supervisor>)qry.list(); 
Experience pair programming with AI  Get Codota for Java