大家好,guzz新手求教spring事务配置
我刚接触guzz,在参照wiki配置spring事务后,执行更新操作都会遇到下面这个异常
org.springframework.dao.DataAccessResourceFailureException: Could not obtain current thread-bounded Guzz WriteTranSession.
at org.guzz.web.context.spring.SpringWriteTemplate.getSession(SpringWriteTemplate.java:122)
at org.guzz.transaction.AbstractWriteTemplate.currentSession(AbstractWriteTemplate.java:58)
at org.guzz.web.context.spring.SpringWriteTemplate.doExecute(SpringWriteTemplate.java:88)
at org.guzz.transaction.AbstractWriteTemplate.executeUpdate(AbstractWriteTemplate.java:153)
applicationContent.xml
解决方案:在Service层的class上声明@Transactional,告诉transactionManager如何去管理你的事务即可。
我刚接触guzz,在参照wiki配置spring事务后,执行更新操作都会遇到下面这个异常
org.springframework.dao.DataAccessResourceFailureException: Could not obtain current thread-bounded Guzz WriteTranSession.
at org.guzz.web.context.spring.SpringWriteTemplate.getSession(SpringWriteTemplate.java:122)
at org.guzz.transaction.AbstractWriteTemplate.currentSession(AbstractWriteTemplate.java:58)
at org.guzz.web.context.spring.SpringWriteTemplate.doExecute(SpringWriteTemplate.java:88)
at org.guzz.transaction.AbstractWriteTemplate.executeUpdate(AbstractWriteTemplate.java:153)
applicationContent.xml
<bean id="guzzContext" class="org.guzz.web.context.spring.GuzzContextBeanFactory" factory-method="createGuzzContext">
<constructor-arg>
<value>/WEB-INF/guzz.xml</value>
</constructor-arg>
</bean>
<bean id="abstractGuzzDao" class="org.guzz.dao.GuzzBaseDao">
<property name="guzzContext" ref="guzzContext" />
</bean>
<!--数据库事务-->
<bean id="transactionManager" class="org.guzz.web.context.spring.GuzzTransactionManager">
<property name="guzzContext" ref="guzzContext" />
</bean>
guzz.xml
<guzz-configs>
<dialect class="org.guzz.dialect.Mysql5Dialect" />
<tran locator="spring">
<dbgroup name="default" masterDBConfigName="masterDB" />
</tran>
<config-server>
<server class="org.guzz.config.LocalFileConfigServer">
<param name="resource" value="guzz.properties" />
</server>
</config-server>
<business-scan resources="classpath*:/com/foo/sms/entity/*/*.class" />
</guzz-configs>
解决方案:在Service层的class上声明@Transactional,告诉transactionManager如何去管理你的事务即可。