Hibernate query giving java.lang.IllegalArgumentException: node to traverse cannot be null

前端 未结 3 1018
刺人心
刺人心 2021-01-03 01:14

This simple query

session = com.jthink.songlayer.hibernate.HibernateUtil.getSession();
Query q = session.createQuery(\"recNo from SongChanges\");
         


        
3条回答
  •  旧巷少年郎
    2021-01-03 01:46

    The SELECT clause provides more control over the result set than the from clause. If you want to obtain few properties of objects instead of the complete object, use the SELECT clause. Following is the simple syntax of using SELECT clause to get just name field of the Employee object:

    String hql = "SELECT E.name FROM Employee E";
    Query query = session.createQuery(hql);
    List results = query.list();
    

    If you want whole object that time "select * from" is not needed.

提交回复
热议问题