findByProperty不提交事务

用框架自动生成的代码,findById就能提交事务,findByProperty不提交事务

action代码

 // 查找管理员
    public String searchAdmin() {
        HttpServletRequest request = ServletActionContext.getRequest();
        String aname = request.getParameter("aname");

        List<Admin> list=iAdminBiz.findByAname(aname);

        request.setAttribute("admin", list);
        return "searchAdmin";

    }


接口

    public List<Admin> findByAname(Object aname);
    @Override
    public List<Admin> findByAname(Object aname) {

        return adminDAO.findByAname(aname);
    }

Hibernate生成代码

    public List findByProperty(String propertyName, Object value) {
        log.debug("finding Admin instance with property: " + propertyName
                + ", value: " + value);
        try {
            String queryString = "from Admin as model where model."
                    + propertyName + "= ?";
            Query queryObject = getSession().createQuery(queryString);
            queryObject.setParameter(0, value);
            return queryObject.list();
        } catch (RuntimeException re) {
            log.error("find by property name failed", re);
            throw re;
        }
    }

    public List findByAname(Object aname) {
        return findByProperty(ANAME, aname);
    }

看看spring的配置文件,也许byId结尾的方法走事务,by~~其他的就不走事务了

看看spring的配置文件,也许byId结尾的方法走事务,by~~其他的就不走事务了

我发现在测试类中能调用该方法,但是在action中却不能调用
但是findById是可以用的,完全不知道是什么问题