*
* @throws Throwable
*/
public void testJustAttachConnections() throws Throwable
{
Transaction tx = null;
Article example;
OTMConnection conn1 = _kit.acquireConnection(PersistenceBrokerFactory.getDefaultKey());
OTMConnection conn2 = _kit.acquireConnection(PersistenceBrokerFactory.getDefaultKey());
try
{
tx = _kit.getTransaction(conn1);
tx.begin();
tx.registerConnection(conn2);
example = (Article) conn1.getObjectByIdentity(
new Identity(Article.class, Article.class,
new Object[]{new Integer(77779)}));
if (example == null)
{
example = Article.createInstance();
example.setArticleId(new Integer(77779));
}
example.setProductGroupId(new Integer(7));
example.setStock(333);
example.setArticleName("333");
conn1.makePersistent(example);
EnhancedOQLQuery query = conn2.newOQLQuery();
query.create("select obj from " + Article.class.getName()
+ " where " + "articleId = " + example.getArticleId());
Article same = (Article) conn2.getIteratorByOQLQuery(query).next();
Assert.assertNotNull("Didn't find object in context of transaction", same);
tx.commit();
}
catch (Throwable ex)
{
try
{
if (tx != null && tx.isInProgress())
{
tx.rollback();
}
}
catch (Exception ex2)
{
}