createTestData();
/**
* first get the contract object.
*/
PersistenceBrokerFactory.defaultPersistenceBroker().clearCache();
Transaction tx = _kit.getTransaction(_conn);
tx.begin();
Criteria crit = new Criteria();
crit.addEqualTo("pk", "C" + TIME);
Query q = QueryFactory.newQuery(Contract.class, crit);
Iterator it = _conn.getIteratorByQuery(q, LockType.WRITE_LOCK);
Object retval = null;
RelatedToContract r2c = new RelatedToContract();
r2c.setPk("R2C" + TIME);
r2c.setRelatedValue1("matt");
r2c.setRelatedValue2(34);
r2c.setRelatedValue3(new Timestamp(TIME));
_conn.makePersistent(r2c);
while (it.hasNext())
{
retval = it.next();
((Contract) retval).setRelatedToContract(r2c);
}
tx.commit();
r2c = null;
tx = _kit.getTransaction(_conn);
tx.begin();
crit = new Criteria();
crit.addEqualTo("pk", "E" + TIME);
q = QueryFactory.newQuery(Effectiveness.class, crit);
it = _conn.getIteratorByQuery(q);
retval = null;
while (it.hasNext())
{
retval = it.next();
}
tx.commit();
assertTrue("contract object should have a RelatedToContract instance attached", ((Effectiveness) retval).getVersion().getContract().getRelatedToContract() != null);
}