-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: JTA connection.release_mode
PostPosted: Mon Jul 28, 2008 6:51 pm 
Newbie

Joined: Mon Jul 28, 2008 3:43 pm
Posts: 2
Hibernate version: 3.2.6.GA

Application server: JBoss 4.2.2

RDBMS: Oracle 10g

The default connection release mode for jta is after_statement, that is connection is released to connection pool after statement.

As far as I know in Oracle each database connection maps to a session, and I don't that session can share multiple branches of different global transactions (in case one branch is active at the given moment and others are suspended)

Is this behavior applicable for Oracle?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 28, 2008 9:19 pm 
Newbie

Joined: Mon Jul 28, 2008 3:43 pm
Posts: 2
Yes I managed to do this:

Code:
public class Test1 {
    public static void main(String[] args) throws SQLException, XAException {

        XAConnection xaCon;
        XAResource xaRes;

        Xid xid1;
        Xid xid2;

        Connection con;
        Statement stmt;
        int ret;

        xaCon = OracleUtils.getXAConnection();

        xaRes = xaCon.getXAResource();

        con = xaCon.getConnection();
        stmt = con.createStatement();

        xid1 = new OracleXID(100, new byte[]{0x01}, new byte[]{0x02});
        xid2 = new OracleXID(100, new byte[]{0x11}, new byte[]{0x22});

        // start and suspend the first transaction's branch
        xaRes.start(xid1, XAResource.TMNOFLAGS);
        stmt.executeUpdate("insert into x1 values (1)");
        xaRes.end(xid1, XAResource.TMSUSPEND);
   
        // start second transaction's branch
        xaRes.start(xid2, XAResource.TMNOFLAGS);

        stmt.executeUpdate("insert into x2 values (2)");
        xaRes.end(xid2, XAResource.TMSUCCESS);

        //prepare and commit second transaction's branch
        ret = xaRes.prepare(xid2);
        if (ret == XAResource.XA_OK) {
            xaRes.commit(xid2, false);
        }

        //resume, prepare and commit first transaction's branch
        xaRes.start(xid1, XAResource.TMRESUME);
        ret = xaRes.prepare(xid1);
        if (ret == XAResource.XA_OK) {
            xaRes.commit(xid1, false);
        }

    }
}



I can conclude that oracle support such behavior))


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.