-->
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: How to write HQL with a Map mapping?
PostPosted: Sat Oct 30, 2004 11:17 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: anyone here?
PostPosted: Tue Nov 02, 2004 12:41 am 
Newbie

Joined: Sat Oct 30, 2004 10:47 pm
Posts: 15
help me:-)


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.