zoukankan      html  css  js  c++  java
  • org.springframework.orm.hibernate3.HibernateQueryException: m_reportuser is not mapped

    dao层

    @SuppressWarnings("unchecked")
    public List<M_REPORTUSER> findVo(String hql) throws Exception {
    return this.getHibernateTemplate().find(hql);
    }

    service层

    public M_REPORTUSER findUserByUserId(String userid) throws Exception {
    M_REPORTUSER us = new M_REPORTUSER();
    try {
    List<M_REPORTUSER> ls = new ArrayList<M_REPORTUSER>();
    String hql = " from m_reportuser where userid = "+userid+"";
    ls = userDao.getUserByhql(hql);
    if(!ls.isEmpty()&&ls.size()>0){
    us = ls.get(0);
    }
    } catch (Exception e) {
    throw e;
    }
    return us;
    }

    报错:org.springframework.orm.hibernate3.HibernateQueryException: m_reportuser is not mapped 

    原因:出现这个错误的根本原因是hql语法里面是POJO对象而不是table.所以把table改为和POJO一模一样就可以了

    String hql = " from M_REPORTUSER where userid = "+userid+"";

  • 相关阅读:
    如何分配资源和管理资源
    让Project把周六和周日也计算工期
    Project设置子任务
    pytest-配置文件
    pytest-fixture
    pytest-标记
    pytest-断言
    pytest-参数化
    pytest入门
    maven-插件
  • 原文地址:https://www.cnblogs.com/m3Lee/p/3711668.html
Copyright © 2011-2022 走看看