[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] JPA Query + enum question
|
You should be able to query on enum types in JPQL, the same as an other basic
mapping. JPQL does not allow :list arguments for IN, so you need to define
an argument for each value. Technically EclipseLink could support list
arguments for IN, but I don't think does yet (although it is supported in
Expressions).
i.e.
@NamedQuery(name = "findRequestInStages", query = "select r from
ImportRequest r where r.importStage in (:stage1, :stage2)")
getEntityManager().createNamedQuery("findRequestInStages").setParameter("stage1",
ImportStage.value1).setParameter("stage2",
ImportStage.value2).getResultList();
Leon Derks-2 wrote:
>
> Is it possible to query for objects which have some kind of enum type?
>
> For example :
>
> @NamedQuery(name = "findRequestInStages", query = "select r from
> ImportRequest r where r.importStage in (:stages)")
> //importStage is an Java 5 Enum.
>
> getEntityManager().createNamedQuery("findRequestInStages").setParameter("stages",
> importStage is an Java 5 Enum.).getResultList();
> //stages is an EnumSet.
>
> I would like to get all the requests that have one of the given stages.
>
> How can I do this?
>
> Leon
>
-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland
http://www.eclipse.org/eclipselink/
EclipseLink , http://www.oracle.com/technology/products/ias/toplink/
TopLink
Wiki: http://wiki.eclipse.org/EclipseLink EclipseLink ,
http://wiki.oracle.com/page/TopLink TopLink
Forums: http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink ,
http://www.nabble.com/EclipseLink-f26430.html EclipseLink
Book: http://en.wikibooks.org/wiki/Java_Persistence Java Persistence
--
View this message in context: http://www.nabble.com/JPA-Query-%2B-enum-question-tp17473509p17491039.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.