-->
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.  [ 1 post ] 
Author Message
 Post subject: Querying ElementCollections
PostPosted: Sun Jun 20, 2010 7:10 am 
Newbie

Joined: Fri Apr 09, 2010 3:55 pm
Posts: 8
Hiya,

Say I have this:

Code:
@ElementCollection
private Set<String> names;


How do I go about querying the set if I have multiple names?

This works for one name:

Code:
from Person where :names in elements(names)


If I have this as a HQL query:

Code:
Query query = getSessionFactory().getCurrentSession().getNamedQuery(query);
query.setProperty("names", "foobar");
query.list()


I get a result back, but if I try this:

Code:
query.setProperty("names", new String[]{"foo", "bar"});


then I get a SQL error:

Code:
ERROR org.hibernate.hql.PARSER:56 - line 1:62: unexpected token: ,


Thanks all in advance.

-=bootlaces=-


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

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.