• Post Reply Bookmark Topic Watch Topic
  • New Topic

Criteria with IN clause that comes from a sub sql  RSS feed

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);
crit.Restriction.in( "foreign_key_a" <some code> );

How do I fit in select primary_key_a where vala1 = 5 for <some code> ?
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!