Liny_@NotePad

沉迷ACG中

no transaction in progress

YOYO posted @ 2010年5月02日 13:03 in 【Java EE】 with tags spring JPA , 7290 阅读

用Spring做事务管理,在配JPA的时候出问题,原来用Hibernate的时候就没问题的,换JPA就报这个错:no transaction in progress

百度不到,google之,得解:

Use the spring transaction annotations (which must be enabled on the context) 
For getters use the @Transactional(propagation = Propagation.SUPPORTS). This will ensure a session will actually be openend. 
For create/update/delete use the @Transactional(propagation = Propagation.REQUIRED) to ensure that a either new transaction will be started, or the call on the DAO participates on the current transaction. 

 

原本只在IBaseDao上注明事务,现在要对每个方法都注解一下才可用,囧rz,不知道会是哪里出了问题。


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter