I am having a problem with the number of queries made asleep to the database. Here is my query log (using Mysql 5.1) to the database when performing a simple selection:
111125 7:18:30
27 Query SET autocommit=0
27 Query SELECT @@session.tx_isolation
27 Query select this_.id as id34_0_, this_.media_id as media3_34_0_, this_.message as message34_0_, this_.user_id as user4_34_0_ from notifications this_
27 Query rollback
27 Query SET autocommit=1
I read a lot about how to set autocommit to 0, and then to 1. I know that the default value for the connection is 1, and this behavior cannot be changed. You can run SET autocommit = 0, but the result will be the same.
Anyway, to avoid any of these queries? I do not know why SELECT @@ session.tx_isolation occurs and rollback. When I use a transaction, I get a commit and then rollback. Not sure why rollback is always connected to the cable.
Thank you so much!
My conf: Spring 2.5.6, Hibernate 3.6.0, Mysql 5.1
datasoure.xml:
<bean id="dataSource" destroy-method="close"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="initialSize" value="3" />
<property name="maxActive" value="20" />
<property name="minIdle" value="3" />
<property name="poolPreparedStatements" value="false" />
<property name="defaultAutoCommit" value="false" />
<property name="defaultTransactionIsolation" value="4" />
</bean>
Transaction Manager Definition:
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
UPDATE.
<property name="defaultReadOnly" value="true" />
, ( , readOnly = false) db, SQLException.
readonly true.
, HibernateTemplate.
aspectj .
<aop:aspectj-autoproxy proxy-target-class="true" />