-->
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.  [ 4 posts ] 
Author Message
 Post subject: Maps & HQL
PostPosted: Mon Jul 18, 2005 4:39 am 
Regular
Regular

Joined: Mon Jul 18, 2005 4:10 am
Posts: 92
Location: Poland
Hi all,

I have general trouble with the syntax of HQL query when reffering "map" (key-value) collections. I've already read docs several times, looked at unit tests, searched forums (hibernate forum too) with no luck. At first, it looks very simple :
Code:
<class name="foo" >
..
<map name="bar">
  <key column="id_foo" />
  <index column="bar_key" />
  <element column="bar_value" />
</map>
</class>
but I have no idea how to refer "key" and "value". I know about "indices" and "elements" but it is not what I need. They allow me to refer key -or- value , not both of them in the same time. I need for example to get objects which contain in their map keys > 10 and values < 100, something like:
Code:
select f from foo f where count( select b from f.bar b where b.KEY>10 and b.VALUE<100)>0

The problem is even bigger witch entity index or element (index-many-to-many, many-to-many).
Please help - the problem affects major part of my application, I have many maps and plenty of ugly loops when dealing with them.

--
michal


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 21, 2005 1:04 pm 
Regular
Regular

Joined: Mon Jul 18, 2005 4:10 am
Posts: 92
Location: Poland
Can't belive it's so difficult :(

An answer that's not possible is also welcome.

_________________
michal


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 21, 2005 2:54 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
I'm not sure about this, but try using indices(b) > 10 and elements(b) < 100, or maybe b.indices and b.elements, or even better, look up elements/indices in the documentation and see if it helps :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 22, 2005 3:52 am 
Regular
Regular

Joined: Mon Jul 18, 2005 4:10 am
Posts: 92
Location: Poland
I think I have to give up :?

Usung b.indicies/b.elements gives "cannot dereference scalar collection element: elements(/indicies)". Using indices(b) ... causes that the NHibernate passes it as sql-function ( sql server says "unrecognized function ...")

I've read docs many times, for now I see that indicies, elements, maxIndex, maxElement ,... are ok when you need to query key -or- value , not both of them.

Thanks for your suggestions anyway.

_________________
michal


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.