-->
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: How to operate in HQL with a Map element
PostPosted: Thu Nov 04, 2004 10:55 pm 
Newbie

Joined: Sat Oct 30, 2004 10:47 pm
Posts: 15
I have mappings like this:
public class Foo {

private Long id;
private Map barMap;
...//getters, setters
}

public class Bar {

private Long id;
private String name;
}

with class Foo, the key of barMap is an object of Bar, and the value is a Date.
<hibernate-mapping>
<class name="Bar">

...
</class>
<class name="Foo">
...
<map name="barMap" table="barMapTable">
<key column="fooId"/>
<index-many-to-many class="Bar" column="barId"/>
<element column="barDate" type="java.util.Date"/>
</map>
</class>
</hibernate-mapping>
so I want to get all Bars object from Foo with a condition of specified Date, how to write the HQL?
Like this?
"select indices(foo.barMap) from Foo foo, foo.barMap barDate where barDate = new Date() ";
I find "indices(foo.barMap)" will join a table such as barMapTable, and "from Foo foo, foo.barMap" will join the table "barMapTable" with another alias, so "indices(foo.barMap)" hasn't any relation with "foo.barMap".


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 04, 2004 11:21 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
elements()


Top
 Profile  
 
 Post subject: it doesn't work
PostPosted: Fri Nov 05, 2004 3:39 am 
Newbie

Joined: Sat Oct 30, 2004 10:47 pm
Posts: 15
elements() will extract the value of the map, but I want the key from the map.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 16, 2004 5:16 am 
Newbie

Joined: Tue Nov 16, 2004 4:51 am
Posts: 1
I met the same question these days, ....

put a <parent...> tag in the composite-element section can solve this problem


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.