Transaction tx = pm.currentTransaction();
tx.begin();
Collection tmp = (Collection)pm.newQuery(
PrimitiveTypes.class, "id == 5").execute();
PrimitiveTypes instance5 = (PrimitiveTypes)tmp.iterator().next();
instance5.setIntNotNull(99);
Collection result = (Collection)pm.newQuery(
PrimitiveTypes.class, "intNotNull == 99").execute();
// check result
if (result.isEmpty()) {
fail(ASSERTION_FAILED,
"Query should find modified instance, but query result is empty");
}
Iterator i = result.iterator();
PrimitiveTypes p = (PrimitiveTypes)i.next();
if (p.getId() != 5L)
fail(ASSERTION_FAILED,
"Query returned wrong instance with id " + p.getId());
if (p.getIntNotNull() != 99)
fail(ASSERTION_FAILED,
"Query returned instance with wrong intNotNull field value " +
p.getIntNotNull());
if (i.hasNext())
fail(ASSERTION_FAILED,
"Query returned more than one instance");
if (debug)