Native SQL throwing Invalid Column Name Exception

前端 未结 3 2032
借酒劲吻你
借酒劲吻你 2021-01-12 01:31

I am using Hibernate 3.2.5 for my application.

I have a Dept table and an Employees table.

Dept.java



        
3条回答
  •  暖寄归人
    2021-01-12 02:15

    you have this in your mapping:

    
    

    but there is no such column in your sql between Select and from:

    session.createSQLQuery("Select d.DEPT_ID, e.EMP_NAME from Dept d,Emp e where d.DEPT_ID = e.DEPT_ID")
    

    Hibernate has no possibilitys to bind the attribute. Try it with this:

    session.createSQLQuery("Select d.DEPT_ID, d.DEPT_NAME, e.EMP_NAME from Dept d,Emp e where d.DEPT_ID = e.DEPT_ID")
    

提交回复
热议问题