no transaction in progress

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

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


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. 



登录 *

loading captcha image...
or Ctrl+Enter