tags:

views:

318

answers:

2

Is it possible to create restriction clauses for the Seam EntityQuery, that are ORed instead of always being ANDed together?

A: 

Take a look at setRestrictionLogicOperator(operator). Operator can be "and" or "or". This will "and" or "or" all restriction statements.

Petar Minchev
A: 

Be aware you can also write everything in the private static final String EJBQL ,EL is interpreted here too, so you can combine OR and AND like this :

select c from Cat c where c.gender=#{cat.gender} and ( c.name=#{cat.name} or c.color=#{cat.color} )

You can even avoid problems with null values like this : where c.name=#{empty cat.name ? "defaultName" : cat.name }

Simon Lebettre