How to specify default transaction isolation level in Grails

I cannot figure out how to specify the default transaction isolation level in a Grails application. Please help and indicate where my mistake is. See below for details.

Grails: 1.3.7

Database: Sql Server 2008.

DataSource.groovy:

dataSource {
  ...
  driverClassName = "net.sourceforge.jtds.jdbc.Driver"
  dialect = org.hibernate.dialect.SQLServerDialect
  defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_UNCOMMITTED
}

hibernate {
  ...
  connection.isolation = java.sql.Connection.TRANSACTION_READ_UNCOMMITTED
}

Then I browse the application and execute the following query:

SELECT session_id, host_name, program_name, login_name, status, transaction_isolation_level
FROM sys.dm_exec_sessions
WHERE host_name IS NOT NULL AND login_name = 'cm'
ORDER BY host_name, program_name

which returns:

session_id  host_name   program_name    login_name  status  transaction_isolation_level
61          ANDREYK-WS  jTDS            cm          running 2

2 means READ_COMMITTED. I expect to see 1, i.e. READ_UNCOMMITTED.

If I explicitly state: @Transactional (isolation = Isolation.READ_UNCOMMITTED)

The query above returns 1 as expected. However, I do not want to bind all services in my application. What am I missing?

+5
source share
2 answers

, ..

dataSource {
  ...
  driverClassName = "net.sourceforge.jtds.jdbc.Driver".
  dialect = org.hibernate.dialect.SQLServerDialect
  properties {
    defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_UNCOMMITTED.
  }
}
+6

, DS

( ):

def defaultConnectionProperties =  [
    maxActive: 50,
    maxIdle: 25,
    minIdle: 5,
    initialSize: 5,
    minEvictableIdleTimeMillis: 60000,
    timeBetweenEvictionRunsMillis: 60000,
    maxWait: 10000,
    defaultTransactionIsolation: java.sql.Connection.TRANSACTION_READ_UNCOMMITTED
]

DS :

dataSource {
    pooled = true
    driverClassName = "net.sourceforge.jtds.jdbc.Driver"
//    driverClassName = "com.p6spy.engine.spy.P6SpyDriver" // use this driver to enable p6spy logging
    //readOnly = "true"
    properties = defaultConnectionProperties
}

Grails.

, _isolation_level = 2, , , , , 1.

: grailsApplication.config

+4

All Articles