cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <do...@xsinet.co.za>
Subject Re: Setting the Transaction Isolation Level
Date Tue, 11 Mar 2014 18:00:46 GMT
Thanks Laurent

I understand the MyPoolManager class but I'm not sure about how to use it as 
you demonstrated.
I am using 3.1 though and have a static method:

public static DataContext getContext()
{
        if ( server == null )
        {
                String  iniFile = .....;
               MyDataSourceModule  module = new MyDataSourceModule( 
iniFile );
                server = new ServerRuntime( "cayenne-Vision.xml", module );
        }
        return (DataContext) server.getContext();
}

So how do I further configure ServerRuntime to accommodate MyPoolManager ?

Thanks,
Jurgen


-----Original Message----- 
From: Laurent Marchal
Sent: Tuesday, March 11, 2014 4:27 PM
To: user@cayenne.apache.org
Subject: Re: Setting the Transaction Isolation Level

Hi Jurgen,

     In Cayenne 3.0 I achieved this by extending PoolManager with my own
class and override the newPooledConnection() method. I don't know about
Cayenne 3.1

Class MyPoolManager :
     @Override
     protected PooledConnection newPooledConnection(String userName,
String password) throws SQLException {
         // override superclass to call stored procedure
         final PooledConnection pConn =
super.newPooledConnection(userName, password);
         Connection connection = pConn.getConnection();
         connection.setAutoCommit(false); // disable auto commit
connection.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
// avoid deadlock on big SELECTs

         return pConn;
     }

To use MyPoolManager do :

         DataDomain domain = _conf.getDomain();
         DataNode node = domain.getNode(CAYENNE_DATANODE);
         try {
             ConnectionPoolDataSource dataSource =
getDataSourceFromConfig(config);
             OpconPoolManager poolManager = new
MyPoolManager(_listenerList, dataSource, config.getDatabaseUser(),
config.getDatabasePassword(), user);
             node.setDataSource(poolManager);
             return poolManager;

         } catch (SQLException e) {
             throw new MyException("Cannot create database connection
pool, bad database configuration: " + config.getDataSourceUrl(), e);
         }

Hope this helps,
Laurent.

On 3/11/14, 8:48 AM, dollj@xsinet.co.za wrote:
> Hi All
>
> I'm using jTDS to connect to a MS SQL db, their default setting for
> transaction isolation is READ_COMMITED which I would like to change.
>
> jTDS doesn't seem to have a property that can be sent via the connection
> URL so that means that I need to change it through Cayenne.
>
> So can anyone show me how one changes the default transaction isolation
> level ?
>
> Thanks
> Jurgen
>
>


Mime
View raw message