Hibernate version:
3.1
Mapping documents:
NA
Code between sessionFactory.openSession() and session.close():
NA
Full stack trace of any exception that occurs:
NA
Name and version of the database you are using:
NA
The generated SQL (show_sql=true):
NA
Debug level Hibernate log excerpt:
NA
First I cannot change the schema :(
I have 2 entities A and B both have a field called firstName. The entities are not associated in any way.
I want to create a subquery using CriteriaQuery and/or DetachedCriteria. I want A to be the subquery of B and B only to return instances where B.firstName is in the results of A.
I have tried the following with no success...
sub = DetachedCriteria.forClass(A.class);
sub.setProjection(Property.forName("firstName"));
sub.add(Restrictions.eq("firstName", "John Doe"));
crit = Session.createCriteriaQuery(B.class)
crit.add(Subquries.eq("firstName", sub));
crite.list();
this returns and empty list. I did verify that "John Doe" was in both tables.
------------------------------------------------------------
Also tried...
crit.add(Property.forname("firstName", sub));
Any ideas of what I am doing wrong?
|