org.springframework.orm.jpa.JpaSystemException: Session is closed!;

错误信息:

org.springframework.orm.jpa.JpaSystemException: Session is closed!; nested exception is org.hibernate.SessionException: Session is closed!

解决办法:

         private EntityManager em;
@PersistenceContext ( unitName = "spring-jpa-creditaudit" )
public void SetEntityManager( EntityManager em ) {
this.em = em;
}

可能是当使用EntityManager时,对应调用的实现类没有加事物:
@Service
@Transactional(readOnly=true)
public class BankServiceImpl implements BankService {

}

猜你喜欢

转载自learningtogrowup.iteye.com/blog/2322141