-->
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: Querying of maps
PostPosted: Mon Oct 17, 2005 3:31 am 
Newbie

Joined: Mon Oct 17, 2005 3:17 am
Posts: 1
Hi.

Is it possible to query for keys and values of a map?

I have a class with an attribute "private Map properties". The mapping is like follows:

<class name="Configuration">
...
<map name="properties">
<key column="configuration_id" not-null="true" />
<map-key column="key" type="string" length="50" />
<element column="value" type="string" length="255" not-null="true" />
</map>
</class>

Now I would like to select all "Configuration" objects which have an entry "testkey" with the value "testvalue" in the map.

I tried "FROM configuration AS c WHERE c.properties.key='testkey' and c.properties.element='testvalue'", but Hibernate complains about the dot between "properties" and "keys".

I also tried "FROM configuration AS c WHERE c.properties.key IS NOT NULL" just to see if there is any possibility to specify the entries of the map, but I always get a "hql.ast.QuerySyntaxError" for the 2nd dot.

I am using Hibernate 3.0.5.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 29, 2006 3:57 pm 
Beginner
Beginner

Joined: Mon Aug 15, 2005 10:20 am
Posts: 32
Location: Brazil
Try:
Code:
from Configuration as configuration
where configuration['testKey'] = 'testValue'

Does it work for you?


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.