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: Criteria query on collection of Strings
PostPosted: Sat Nov 03, 2007 11:24 pm 
Newbie

Joined: Tue Apr 03, 2007 11:40 am
Posts: 7
Location: London
I have a collection of strings defined as follows:
List<String> names

and mapped as follows...

<idbag name="names" table="t_object_names">
<collection-id column="id" type="long">
<generator class="sequence">
<param name="sequence">
sequence_id
</param>
</generator>
</collection-id>
<key column="object" not-null="true" />
<element column="name" type="java.lang.String"/>
</idbag>


... and I'm trying to figure out how I can use a Criteria query to return those objects which have a particular name (i.e pass a String in, and get those objects which have this value in their List of names)

I'm trying

criteria.createAlias("names", "n", CriteriaSpecification.LEFT_JOIN)
.add(Restrictions.eq("n.name", name));

but this gives me an error:
"collection was not an association"

Does anyone know whether I can use Criteria queries to do this ?
I need them because this restriction has to be applied alongside many others, conditionally.

_________________
----
Matt


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 05, 2007 6:20 am 
Newbie

Joined: Fri Jul 20, 2007 4:32 am
Posts: 4
Please see

http://www.hibernate.org/117.html#A2


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.