Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@76ebf212] was not registered for synchronization because synchronization is not active
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7c61b8bc] was not registered for synchronization because synchronization is not active
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6aa9548e] was not registered for synchronization because synchronization is not active
JDBC Connection [jdbc:mysql://localhost:3307/ge_test, UserName=root@localhost, MySQL Connector Java] will not be managed by Spring
JDBC Connection [jdbc:mysql://localhost:3307/ge_test, UserName=root@localhost, MySQL Connector Java] will not be managed by Spring
JDBC Connection [jdbc:mysql://localhost:3307/ge_test, UserName=root@localhost, MySQL Connector Java] will not be managed by Spring
控制台提示,我每次执行SQL的时候都会Creating a new SqlSession,这样是不是会严重的影像性能?我明明配置了事务,而且测试过事务是有效的,为什么还提示我事务没有交给spring管理呢?事务配置代码:<!-- 事务管理器配置 -->
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean> <!-- 事务传播特性配置 -->
<tx:advice id="transactionAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="save*" propagation="REQUIRED" rollback-for="Exception"/>
<tx:method name="delete*" propagation="REQUIRED" rollback-for="Exception"/>
<tx:method name="update*" propagation="REQUIRED" rollback-for="Exception"/>
<tx:method name="get*" read-only="true" />
</tx:attributes>
</tx:advice> <!-- 配置哪些方法参与事务 -->
<aop:config proxy-target-class="true">
<aop:pointcut id="transactionxPointcut" expression="execution(* com.kwjq.web.service.*.*(..))" />
<aop:advisor advice-ref="transactionAdvice" pointcut-ref="transactionxPointcut" />
</aop:config>亲自测试过,如果在Service里面执行2个dao方法,第一个执行完毕后,我手动抛出异常,是会回滚的。请问各位,为什么会出现这样的情况?
问题一、为什么每次都Creating a new SqlSession,会不会影响性能?
问题二、明明配置了事务,确提示事务没有交给spring管理,求解。谢谢各位大神,有满意答案就结贴给分。
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@76ebf212] was not registered for synchronization because synchronization is not active
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7c61b8bc] was not registered for synchronization because synchronization is not active
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6aa9548e] was not registered for synchronization because synchronization is not active
JDBC Connection [jdbc:mysql://localhost:3307/ge_test, UserName=root@localhost, MySQL Connector Java] will not be managed by Spring
JDBC Connection [jdbc:mysql://localhost:3307/ge_test, UserName=root@localhost, MySQL Connector Java] will not be managed by Spring
JDBC Connection [jdbc:mysql://localhost:3307/ge_test, UserName=root@localhost, MySQL Connector Java] will not be managed by Spring
控制台提示,我每次执行SQL的时候都会Creating a new SqlSession,这样是不是会严重的影像性能?我明明配置了事务,而且测试过事务是有效的,为什么还提示我事务没有交给spring管理呢?事务配置代码:<!-- 事务管理器配置 -->
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean> <!-- 事务传播特性配置 -->
<tx:advice id="transactionAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="save*" propagation="REQUIRED" rollback-for="Exception"/>
<tx:method name="delete*" propagation="REQUIRED" rollback-for="Exception"/>
<tx:method name="update*" propagation="REQUIRED" rollback-for="Exception"/>
<tx:method name="get*" read-only="true" />
</tx:attributes>
</tx:advice> <!-- 配置哪些方法参与事务 -->
<aop:config proxy-target-class="true">
<aop:pointcut id="transactionxPointcut" expression="execution(* com.kwjq.web.service.*.*(..))" />
<aop:advisor advice-ref="transactionAdvice" pointcut-ref="transactionxPointcut" />
</aop:config>亲自测试过,如果在Service里面执行2个dao方法,第一个执行完毕后,我手动抛出异常,是会回滚的。请问各位,为什么会出现这样的情况?
问题一、为什么每次都Creating a new SqlSession,会不会影响性能?
问题二、明明配置了事务,确提示事务没有交给spring管理,求解。谢谢各位大神,有满意答案就结贴给分。
纳尼?都是正常的?数据库连接是给spring进行管理的,我把数据库连接池的代码贴出来<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="${jdbc.driver}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<!-- 初始化连接大小 -->
<property name="initialSize" value="10"></property>
<!-- 连接池最大数量 -->
<property name="maxActive" value="50"></property>
<!-- 连接池最大空闲 -->
<property name="maxIdle" value="${jdbc.maxIdle}"></property>
<!-- 连接池最小空闲 -->
<property name="minIdle" value="${jdbc.minIdle}"></property>
<!-- 获取连接最大等待时间 -->
<property name="maxWait" value="${jdbc.maxWait}"></property>
</bean>
第二个就很迷了,大概是空闲连接,spring暂时不管?
史上最简单的spring+springMVC+mybaits整合SSM框架~Simple-SSM