public void test() {
    Session session = getSession();
    UnitOfWork uow = session.acquireUnitOfWork();
    uow.setShouldNewObjectsBeCached(true);

    Weather weather = new Weather();
    weather.setStormPattern("Something really bad");
    weather.id = 0;
    ReadObjectQuery query = new ReadObjectQuery(weather);
    query.checkCacheOnly();
    Weather weatherClone = (Weather) uow.registerObject(weather);
    weather = (Weather) uow.executeQuery(query);
    zeroFailed = weather == null;

    Weather weatherNeg = new Weather();
    weatherNeg.setStormPattern("Something really bad below zero");
    weatherNeg.id = -1;
    ReadObjectQuery queryNeg = new ReadObjectQuery(weatherNeg);
    queryNeg.checkCacheOnly();
    Weather weatherNegClone = (Weather) uow.registerObject(weatherNeg);
    weatherNeg = (Weather) uow.executeQuery(queryNeg);
    negativeFailed = weatherNeg == null;

    if (keepSequencing) {
      uow.assignSequenceNumbers();
      zeroOverridden = weatherClone.id != 0;
      negativeOverridden = weatherNegClone.id != -1;
    }
  }
 /** 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);
 }