-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Use of primitive ElementCollection properties in JPAQL
PostPosted: Tue Jul 20, 2010 11:46 am 
Newbie

Joined: Mon Jan 25, 2010 8:30 am
Posts: 7
I am using JPA 2, Hibernate 3.5.3 and have an entity with a collection of primitives (Strings) mapped via ElementCollection. I'd like to construct a JPAQL query that includes a "if in collection" clause.

My entity is like this:

[code]

public class Group {

@ElementCollection
@CollectionTable(name = "GRP_MEMBER")
private List<String> members;

// other properties
}
[/code]

Here are the queries I've tried so far:
select g from Group g where g.members = :personKey
select g from Group g, in(g.members) member where member = :personKey
select g from Group g join g.members member where member = :personKey

The first one fails because of a type mismatch since members is a collection and personKey is a String. The later two fail because "member" is seen as an invalid token.

Is there a way to do what I'm trying to do?


Top
 Profile  
 
 Post subject: Re: Use of primitive ElementCollection properties in JPAQL
PostPosted: Tue Jul 20, 2010 3:31 pm 
Newbie

Joined: Mon Jan 25, 2010 8:30 am
Posts: 7
Turns out the later two options do work but the problem is that "member" is a reserved word, changing it to something like "m" or "mbrs" or whatever makes both work just fine.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.