I need to write a generic NamedQuery; such as, find me all the objects where any of the attributes matches the given parameter.
select mo from MyObject mo where mo.ANYAttribute = someParameter
I could not figure out the expression for "where mo.ANYAttribute". The sort of wildcard such as " + or * or ANY or .)... Something that will save me from writing query where I have to write manually to check for each attribute such as:
where mo.attribute1= :someParameteror or mo.attribute2 = :someParameter
I am using JPA 2.0.
Is it possible this way or I have to change my approach?
Many Thanks, Nav
You need to list all attributes of an entity, there is no such thing as ANYAttribute in JPA:
where mo.attr1=:someParamter or mo.attr2=:someParameter etc.