Hi,
I am trying to fetch all entities from the database, filtered by a given entity A which is in a many-to-one relationship with another entity B.
The problem is in the select statement generated by Hibernate. In the WHERE clause, only the fields from entity A appear, not the ones from
the joined entity B. So if I change the fields in B, but not the fields in A,
List<T> ret from the code below will contain one element, even
though there is no such entity in the database.
Code:
List<T> ret = null;
Session session = getSession();
Criteria crit=session.createCriteria(getPersistentClass());
Example ex= Example.create(entity); // entity A
crit.add(ex);
ret=crit.list();
What am I doing wrong ?
Any help would be highly appreciated.
Thanks.
Andrei