解决方案 »

  1.   

    遇到同样的问题,在线等解答
    userid不是外键吧?或者是复合主键中的某一个?
      

  2.   

    那是不是复合主键中的一个……像这个说的这个样子的http://bbs.csdn.net/topics/390454786
      

  3.   

    我遇到的差不多,public List<T> findByProperty(String className,String propertyName, Object value) {
    /*log.debug("finding "+className+" instance with property: " + propertyName + ", value: " + value);
    */
    try {
    System.out.println(value);
    String hql = "FROM "+className+" as o WHERE o."+propertyName+" = ?";
    Query queryObject = getSession().createQuery(hql);
    queryObject.setParameter(0,value);

    return queryObject.list();
    } catch (RuntimeException re) {
    log.error("find by property name failed", re);
    re.printStackTrace();
    throw re;
    } finally{
    closeSession();
    }
    }
    return直接就走下面异常,
    java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
    我没转换,就属性查询就报异常...