Criteria: search for two different entity classes...

Posted by RoCMe on Stack Overflow See other posts from Stack Overflow or by RoCMe
Published on 2010-05-25T16:23:20Z Indexed on 2010/05/25 16:31 UTC
Read the original article Hit count: 129

Filed under:
|

Hi!

I have a "super entity" SuperEntity and three entities ChildEntity1, ..., ChildEntity3 which extends the super class.

It's easy to search for all entities in the database, i.e. we could use

session.createCriteria(SuperEntity.class);

It's no problem to search for one specific entity type, too, just replace the SuperEntity with any of the children to look for entities of that type.

But I have a problem when allowing 'multiple choice' for the types. I.e., it could be neccessary to search all entities of type 1 and 2, but not of type 3.

A first idea was to create two independent queries and join the results in a final list - but that would destroy the paging which uses offset and limit functionality of the database...

Is there a possibility in Criteria to join two different queries in one single result list?

Kind regards,

RoCMe

© Stack Overflow or respective owner

Related posts about java

Related posts about criteria