Search in sources :

Example 6 with ExternalTransaction

use of org.apache.cayenne.tx.ExternalTransaction in project cayenne by apache.

the class DataContextProcedureQueryIT method runProcedureSelect.

protected List<DataRow> runProcedureSelect(ProcedureQuery q) throws Exception {
    // Sybase blows whenever a transaction wraps a SP, so turn off
    // transactions
    // TODO: it is quite the opposite with PostgreSQL. If an SP returns an
    // open refcursor, it actually expects a TX in progress, so while we
    // don't have refcursor unit tests, this is something to keep in mind
    // e.g.
    // http://stackoverflow.com/questions/16921942/porting-apache-cayenne-from-oracle-to-postgresql
    BaseTransaction t = new ExternalTransaction(jdbcEventLogger);
    BaseTransaction.bindThreadTransaction(t);
    try {
        return context.performQuery(q);
    } finally {
        BaseTransaction.bindThreadTransaction(null);
        t.commit();
    }
}
Also used : ExternalTransaction(org.apache.cayenne.tx.ExternalTransaction) BaseTransaction(org.apache.cayenne.tx.BaseTransaction)

Aggregations

BaseTransaction (org.apache.cayenne.tx.BaseTransaction)6 ExternalTransaction (org.apache.cayenne.tx.ExternalTransaction)6 Artist (org.apache.cayenne.testdo.testmap.Artist)3 Test (org.junit.Test)3 ProcedureQuery (org.apache.cayenne.query.ProcedureQuery)2 SelectQuery (org.apache.cayenne.query.SelectQuery)2 Painting (org.apache.cayenne.testdo.testmap.Painting)2 Transaction (org.apache.cayenne.tx.Transaction)1