-->
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: check if a Map value exists
PostPosted: Wed Nov 10, 2004 6:43 pm 
Regular
Regular

Joined: Tue Jan 27, 2004 12:22 pm
Posts: 103
How do you check if a Map value exists?

In the basic simple map situation (String index,String value), I used:
Code:
from obj o where o.map['key.to.check'] is not null

This works.

Now I have an object with a composite element:
Mapping
Code:
      <map name="variables" table="CUSTOMERVARIABLES" cascade="all" lazy="true" order-by="TIME_OF_CREATION" >
         <key column="ID"/>
         <index column="NAME" type="string"/>
         <composite-element class="nl.dennie.vikie.model.CustomerVariable">
            <property name="timeOfCreation" column="TIME_OF_CREATION" type="calendar"/>
            <property name="value" column="VALUE" type="string"/>
         </composite-element>
      </map>

The same check gives the following exception:
Exception
Code:
net.sf.hibernate.QueryException: path expression ended in composite collection element [from nl.dennie.vikie.model.Company c where c.variables['fetch.mail'] not is null]


Can somebody tell me how to do this? Or should I simply do an inner join on the map and check on it ?

_________________
Dencel
- The sun has never seen a shadow -


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 11, 2004 5:05 am 
Regular
Regular

Joined: Tue Jan 27, 2004 12:22 pm
Posts: 103
problem solved. I upgraded my database to support subselects.
I can now use:
Code:
from Obj o where 'key' in indices(o.map)


This is explained in chapter 11 of the Hibernate documentation.

Greetz

_________________
Dencel
- The sun has never seen a shadow -


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.