• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Write Sub Query in Hibernate help

Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All.
Please help me to right sub query in Hibernate
i have 2 table

my requirement is that when i apply filter apply on quotes table

select quote_id,Quote_name,Quote_dir from quote q where q.quote_name like 'j%';

i get all quote_id from above query

i need to pass above quote_id to another table (programs)
i need following query in Criteria format

select q.quote_id,q.Quote_name,q.Quote_dir ,p.program_name from quote q,program p where q.quote_name like 'j%'
and p.quote_id in(select quote_id from quote where quote_name like 'j%');

please help me its very very urgent
i hope you all geeks help me


Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jone,

I'm not sure what your underlying schema is but can you not write the query using a join rather than a subquery:

Again, depending on your Hibernate mappings this relationship (between Quotes and Programs) may already be defined so you might be able to return the associated programs as a collection in your quote after filtering on the quote name. This of course will depend on your mappings, whether the association is set up, and which direction the association runs in.


I don't get it. A whale wearing overalls? How does that even work? It's like a tiny ad wearing overalls.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic