0

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!!

1 Answer 1

3

You need to give table aliases. Then it will work

from TablePersistence table1 where table1.column1 not in (select table2.column2 from TablePersistence table2)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.