Reputation: 743
I am trying to write a sub query in this format
listObj = session.createQuery("from TablePersistence where column1 not in (select column2 from TablePersistence)").list();
Note that I use a different column of the same table in the sub query.
But I get an exception when it is executed. The exception message is:
No data type for node: org.hibernate.hql.ast.tree.IdentNode
\-[IDENT] IdentNode: 'column2' {originalText=column2}
I can provide the stack trace as well if needed.
But what I feel from looking at the stack trace is that, this is not the way to write a sub query, I am missing something.
Please tell me what is the problem with this query.
Thanks!!
Upvotes: 0
Views: 837
Reputation: 2339
You need to give table aliases. Then it will work
from TablePersistence table1 where table1.column1 not in (select table2.column2 from TablePersistence table2)
Upvotes: 3