就是因为一个注解 就一个上午

@Transactional
public class BaseDaoImpl<T extends Serializable> implements BaseDao<T> {
protected Logger log = LoggerFactory.getLogger(getClass());

// HibernateTemplate

protected SessionFactory sessionFactory;

@Resource
public void setSessionFactory(SessionFactory sessionFactory) {
System.out.println("the set sesionF");
this.sessionFactory = sessionFactory;
}



否则,是出: No Hibernate Session bound to thread, and configuration does not allow create of non-transactional one here


只是现在还是不太明白, 为什么 事务要在DAO上 配,不是SERVICE层吗?

你可能感兴趣的:(Hibernate,getSession)