Native SQL throwing Invalid Column Name Exception
I had the same issue.
The reason is my column name in annotation is not correct.
@Column(name = "CUSTOMER_NAME", length = 200)
should be changed to
@Column(name = "CUST_NM", length = 200)
you have this in your mapping:
<column name="DEPT_NAME"></column>
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")