/** Read employee and clear the cache, test database read. */ public void test() throws Exception { ReadObjectQuery query = new ReadObjectQuery(Employee.class); ExpressionBuilder employee = new ExpressionBuilder(); query.setSelectionCriteria( employee .get("firstName") .equal("Brendan") .and(employee.get("salary").equal(100000)) .and(employee.get("address").get("city").like("%pean%")) .and(employee.anyOf("phoneNumbers").get("type").equal("Home"))); query.checkCacheOnly(); Employee result = (Employee) getSession().executeQuery(query); }
/** Read all employees with salary > 0. */ public void test() throws Exception { ReadAllQuery query = new ReadAllQuery(Employee.class); ExpressionBuilder builder = new ExpressionBuilder(); query.setSelectionCriteria(builder.get("salary").greaterThan(0)); List results = (List) getSession().executeQuery(query); }