Code example for Session

Methods: createQuery

0
    } 
 
    @Override 
    public List<UserSubstitution> getActiveSubstitutions(UserData user, Date date) {
        Session session = getSession();
        return session.createQuery("from UserSubstitution where userSubstitute = :user and :date between dateFrom and dateTo")
            .setParameter("user", user)
            .setParameter("date", date)
            .list();                        
//        return session.createCriteria(UserSubstitution.class) 
//                .add(eq("userSubstitute", user)) 
//                .add(ge("dateFrom", date)) 
//                .add(le("dateTo", date)) 
//                .list(); 
    } 
 
	@Override 
	public List<UserData> getSubstitutedUsers(UserData user, Date date) {
		Session session = getSession();
		return session.createQuery("select distinct us.user from UserSubstitution us where us.userSubstitute = :user and :date between us.dateFrom and us.dateTo")
Contextual code suggestions in your IDE  Get Codota for Java