package dao;
import java.util.List;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
import domain.User;
public class UserDaoImpl extends HibernateDaoSupport implements IUserDao {
@
Override
public void add(User user) {
this.getHibernateTemplate().save(user);
}
@
Override
public void update(User user) {
this.getHibernateTemplate().update(user);
}
@
Override
public void del(User user) {
this.getHibernateTemplate().delete(user);
}
@
Override
public User findById(int id) {
return this.getHibernateTemplate().get(User.class,id);
}
@
Override
public List<User> findAll() {
return (List<User>) this.getHibernateTemplate().find("from User");
}
}
没有声明事务管理, 与切面会报这个错误! 查询也是如此.
org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.