Reputation: 1299
This is my SQL query
select * from customer where cust_acnt_nbr IN
(select cust_acnt_nbr from Asset where dstrct_id IN
(select dstrct_id from dstrct where dstrct_nm = 'ATLANTA'))
I converted this SQL to HQL
final Query query = getCurrentSession().createQuery(
"from customer where cust_acnt_nbr in (select cust_acnt_nbr from Asset where dstrct_id in (select dstrct_id from dstrct where dstrct_nm = :name))");
query.setParameter("name", districtName);
This give an error :
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.hql.internal.ast.QuerySyntaxException: customer is not mapped [from customer where cust_acnt_nbr in (select cust_acnt_nbr from com.ironmountain.model.Asset where dstrct_id in (select dstrct_id from dstrct where dstrct_nm = :name))]
Upvotes: 2
Views: 4039
Reputation: 352
I had this problem , hibernate is case sensitive. this query was my query : Query query = session.createQuery(" select e from student e where e.id=:id");
and i changed student to Student, this query is correct : Query query = session.createQuery(" select e from Student e where e.id=:id");
Upvotes: 0
Reputation: 5269
If you take a closer look here: customer is not mapped
, i think it will be clear. The problem is that Hibernate can't find the customer
entity. Java classes and properties are case sensitive in HQL, maybe customer
is meant to be Customer
.
Upvotes: 4