5
回答
hibernate.connection.autocommit=false没有效果
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   
<!--Define the sessionFactory of hibernate4 -->
	<bean id="sessionFactory"
		class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
		<property name="dataSource">
			<ref bean="dataSource" />
		</property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
				<prop key="hibernate.show_sql">true</prop>
				<prop key="hibernate.connection.autocommit">false</prop>
				<prop key="hibernate.current_session_context_class">org.springframework.orm.hibernate4.SpringSessionContext
				</prop>
			</props>
		</property>
		
	</bean>


这样配置过后DAO层里使用sessionFactory.getCurrentSession().saveOrUpdate()方法仍然可以保存到数据库.求解?

事务配置

<tx:advice id="txAdvice" transaction-manager="txManager">
		<!-- the transactional semantics... -->
		<tx:attributes>
			<!-- all methods starting with '*' are read-only -->
			<tx:method name="get*" read-only="true" />
			<!-- other methods use the default transaction settings (see below) -->
			<tx:method name="add*" propagation="REQUIRED" />
			<tx:method name="*" read-only="true" />
		</tx:attributes>
	</tx:advice>

	<aop:config proxy-target-class="true">
		<aop:advisor advice-ref="txAdvice"
			pointcut="execution(* 项目..*.*(..))" />
	</aop:config>




举报
yongzhong
发帖于4年前 5回/2K+阅
顶部