• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HQL to get all the records in one table but in not other

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am looking for HQL query to get all the records in first query which are not in second query.

For example:

select * from table where
column in
(select column from table where condition
GROUP BY column
having count(column)= 1

NOT IN

(select column from table
where condition
)
)
and condition

The query works in postgreSQL.

Here i am getting error like org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: not in near line 1

Please help me.


Thanks,
Aruna
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code snippets.

You need to try to write this in HQL yourself first, if you get stuck people will be more than happy to help you, but we are NotACodeMill

I would start the reference docs to help get a basic understanding, there are also lots of examples.
http://docs.jboss.org/hibernate/orm/3.6/reference/en-US/html_single/#queryhql

Remember while similar to SQL it is not the same. You have to think in terms of your domain objects. For example you would not select * you would select your object.
 
Nisha lakshminaraya
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried this query in HQL using NOT IN , except clause's but it still didnt work. After trying for three days i am posing this
 
Bill Gorder
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well not in is a valid HQL expression. ItDoesntWorkIsUseless, you have posted the SQL which is a good way to show us what you are trying to achieve. What we are missing is the HQL you are trying and a better description (like a stack trace) with the error you are getting. If you post the HQL that you are trying we may be able to give you pointers as to why it is not working.
 
reply
    Bookmark Topic Watch Topic
  • New Topic