Spring-Hibernate - No Session found for current thread

In your SpringBean.xml you should uncomment <tx:annotation-driven/>:

<tx:annotation-driven transaction-manager="transactionManager"/>

And then you should annotate the CustomerServiceImpl.saveCustomer method as @Transactional:

@Service
public class CustomerServiceImpl implements CustomerService {

    ...

    @Override
    @Transactional
    public void saveCustomer(Customer customer) {
        customerDaoImpl.saveCustomer(customer);
    }

    ...
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章