I would need to perform a criteria query on two unrelated tables (entities) that, if I was using HQL instead of the Criteria API, I would query using something like this:
Code:
SELECT <field_list> FROM entity1,entity2 WHERE entity1.a_field=entity2.another_field AND <extra_conditions>
It must be noted that that
a_field and
another_field are not primary/foreign keys of these tables. Additionally, since one of the tables is updated by an external application and has a fixed structure, I cannot add a foreign key to it.
That's why I cannot join the two entities using createCriteria() or createAlias(). On the other hand the Criteria API doesn't seem to support more than one root entity, so I cannot directly translate the above HQL query into a sequence of Criteria API calls. Nevertheless, I would like to be able to use the Criteria API instead of HQL because the
<extra_conditions> mentioned in the HQL query above are variable, depending on user input.
Do I have any chance of using the Criteria API under these circumstances?
Thanks in advance.