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".
|