Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Criteria with IN clause that comes from a sub sql

Dheeman Basu
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I create IN Restriction using sub query?

Here are my tables
Table A ( primary_key_a, vala1, vala2, ....... )
Table B ( primary_key_b, foreign_key_a, valb1, valb2, ..........)

I want to select records from table B ( mapped in hibernate by BeanB) with certain foreign_key_a values ( say the ones with vala1 = 5, select primary_key_a where vala1 = 5)

My Hibernate code:
Session session = sessionFactory.openSession();
Criteria crit = session.createCriteria(BeanB.class); "foreign_key_a" <some code> );

How do I fit in select primary_key_a where vala1 = 5 for <some code> ?
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!