Set isolation level using CFTRANSACTION AND ORM EntityLoad

I work with ColdFusion 9 and MS SQL Server.

I am trying to use:

<cftransaction isolation="read_uncommitted">
   <cfset X = EntityLoad('table',row_id,true)>
</cftransaction>

to change the isolation level in some transactions

but looking at the log from the data source, I got the following:

09:20:32.688)>> Connection[6].prepareStatement(String sql)
09:20:32.688)>> sql = select ..... _ID=?
09:20:32.688)>> OK (PreparedStatement[871])
09:20:32.689)>> PreparedStatement[871].executeQuery()
09:20:33.594)>> OK (ResultSet[989])
09:20:33.606)>> Connection[6].setTransactionIsolation(int level)
09:20:33.606)>> level = 1
09:20:33.962)>> OK
09:20:34.141)>> Connection[6].setTransactionIsolation(int level)
09:20:34.141)>> level = 2
09:20:34.501)>> OK

If I replace EntityLoad for a simple cfquery call, I get the following:

09:24:30.164)>> Connection[6].setTransactionIsolation(int level)
09:24:30.164)>> level = 1
09:24:30.519)>> OK
09:24:30.519)>> Statement[37].execute(String sql, int autoGeneratedKeys)
09:24:30.519)>> sql = select ...
09:24:30.519)>> autoGeneratedKeys = 1
09:24:30.699)>> OK (true)
09:24:30.879)>> Connection[6].setTransactionIsolation(int level)
09:24:30.879)>> level = 2
09:24:31.234)>> OK

So it seems that when I use ORM EntityLoad, the isolation level is set incorrectly.

Does anyone know why? And what would be the best way to set isolation levels using ORM?

+4
source share
1 answer

ColdBox Curt Gratz: Coldfusion ORM - ... , . , hibernate, .

:

, , ormsettings, hibernate.

, , , "" , ColdFusion , , , . .

http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html

, - ...

hibernate.

<?xml version='1.0' encoding='utf-8'?>

<!DOCTYPE hibernate-configuration PUBLIC

"-//Hibernate/Hibernate Configuration DTD//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

<!-- a SessionFactory instance listed as /jndi/name -->

<session-factory

name="java:hibernate/SessionFactory">

<!-- properties -->

<property name="connection.isolation">1</property>

</session-factory>

</hibernate-configuration>

. <property name="connection.isolation">1</property>. ...

int .

java.sql.Connection
public static final int   TRANSACTION_NONE                0
public static final int   TRANSACTION_READ_COMMITTED      2
public static final int   TRANSACTION_READ_UNCOMMITTED    1
public static final int   TRANSACTION_REPEATABLE_READ     4
public static final int   TRANSACTION_SERIALIZABLE        8

: http://java.sun.com/j2se/1.5.0/docs/api/constant-values.html#java.sql.Connection.TRANSACTION_READ_COMMITTED

application.cfc

<cfset this.ormsettings = {dialect="MicrosoftSQLServer", ormconfig="hibernate.xml"}>  

, hibernate.xml - webroot, .

, , , , .

Curt Gratz .
  , .

+1

Source: https://habr.com/ru/post/1612397/


All Articles