I have an object within an object and want to create a restriction using one of the fields within the inner most object. Now i figured it could be achieved by doing something like:
... .add(Restrictions.eq("myObjectTwp.myObjectThree.myObjectsID", mySearchId)).list();
However this does not seem to work. However, I get no error message and instead it almost looks like this restriction has not been taken into account.
You need to make a join. In the criteria API, the easiest way to do that is to use the createAlias() method:
This query is equivalent to the following HQL: