Exception in thread "main" org.hibernate.QueryException: 
could not resolve property: name of: com.hibernate.school.School 
[from com.hibernate.school.School school inner join fetch school.name]我要把students表中的name加到school中显示 出现这种错误。

解决方案 »

  1.   

    用了之后.直接把SET装满.否则SET里是空的.
      

  2.   

    你说的set是关联配置中set节点?还是集合set?
    我不是太明白你的意思?我是用list集合存储结果的。
      

  3.   

    你的关联关系是什么样的啊?一对多,多对多,
    实体类里有SET集合.或者LIST集合.来保存多方的对像.用FETCH之后,填充这个集合.
      

  4.   

    首先我有两个表students(id,name,age,sch(school))和school(id,school_name,students(set))的例子,是双向一对多的关系。public void InnerJoin() {
    Session session = null;
    try {
    session = this.getSession();
    session.getTransaction().begin();
    String hql = "from School school inner join fetch school.name";
    List list = session.createQuery(hql).list();
    Iterator it = list.iterator();
    while (it.hasNext()) {
    School results = (School) it.next(); System.out.println(results.getSchool_name());
    }
    session.getTransaction().commit();
    } catch (RuntimeException e) {
    this.rollback(session);
    throw e;
    } finally {
    this.close(session); }
    }
    这是我的简单的代码,您先看看。
    具体的hbm.xml文件我就不写了很简单。