I am trying to use a transaction across multiple domains.
But it seems to me that each domain uses a separate
connection, which means that one domain cannot get
access to data on the other connection. For example, when
I try to write with one domain and read with a duplicate
domain:
TestDomain dmn1 = null;
TestDomain dmn2 = null;
TestPO po = null;
List all = null;
JRFTransaction wt = null;
int i = 0;
dmn1 = new TestDomain();
dmn2 = new TestDomain();
po = (TestPO) dmn1.newPersistentObject();
wt = new JRFWriteTransaction();
try {
//begin trans
wt.addDomain(dmn1);
wt.addDomain(dmn2);
wt.beginTransaction();
i = dmn1.countWhere("");
if (i != 0)
throw new AssertionError("i!=0:" + i);
i = dmn2.countWhere("");
if (i != 0)
throw new AssertionError("i2!=0:" + i);
dmn1.save(po);
i = dmn1.countWhere("");
if (i == 0)
throw new AssertionError("i==0:" + i);
i = dmn2.countWhere("");
//FAILS HERE! - because dmn2 not same
connection as dmn1.
if (i == 0)
throw new AssertionError("i2==0:" + i);
all = dmn1.findAll();
if (all.size() == 0)
throw new AssertionError("all==0:" + all.size());
all = dmn2.findAll();
//FAILS HERE! - because dmn2 not same
connection as dmn1.
if (all.size() == 0)
throw new AssertionError("all2==0:" + all.size());
//end trans
wt.endTransaction();
} catch (Throwable t) {
t.printStackTrace();
wt.abortTransaction();
}
Logged In: YES
user_id=1293498
p.s. In jrf-1.7.2, I would use:
JDBCHelper helper = JDBCHelperPool.getFrom("test");
dmn1.setJDBCHelper(helper);
dmn2.setJDBCHelper(helper);
helper.beginTransaction();
What is the jrf-2.0 equivalent?