Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
I'm trying to create a general search facility via the Criteria and Example API, and when trying to create an sub Example that contains only a PK, it is not used when quering.
I have a business object BO1 which has a association with a BO2.
I start creating a Criteria object by adding an exampleof BO1, and linking a SubCriteria where I add the Example of BO1.getBO2().
Here is the code
Code:
DetachedCriteria detachedCriteria = DetachedCriteria.forClass(BO1.class);
detachedCriteria.add(Example.create(bo1Filter));
// add the criteria for the related objects.
if(bo1Filter.getBO2() != null) {
detachedCriteria.createCriteria("bo2").add(Example.create(bo1Filter.getBO2()));
}
What am I doing wrong?
It seems that only the properties are used as part of the where clause and not the Identifier when available.
Any help is welcome.
Kind regards,
Nico