A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
this week in the
Object Relational Mapping
Criteria with IN clause that comes from a sub sql
Joined: Mar 17, 2009
Jan 18, 2012 12:09:49
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> ?
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Criteria with IN clause that comes from a sub sql
hibernate either / or query?
Hibernate Performance for CRITERIA / SELECT Queries..
comparing two table - hibernate criteria
JDBC/SQL/Financial Interview Question
Hibernate Criteria API Select some fields..
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015