tx.begin();
// QueryBuilder is the sessionFactory for queries
QueryBuilder builder = session.getQueryBuilder();
// QueryDomainType is the main interface
QueryDomainType dobj = builder.createQueryDefinition(Employee.class);
// parameter name
PredicateOperand lower = dobj.param("lower");
// parameter name
PredicateOperand upper = dobj.param("upper");
// property name
PredicateOperand column = dobj.get("id");
// compare the column with the parameter
Predicate compare = column.between(lower, upper);
// set the where clause into the query
dobj.where(compare);
// create a query instance
Query query = session.createQuery(dobj);
// set the parameter values
query.setParameter("lower", 5);