Hi,
I have a problem to do the mapping of my map.
I have an entity Node.
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="it.quix.extensibility.model">
<class name="Node" table="cat_node">
<id name="id" column="id" type="long" unsaved-value="0">
<generator class="increment"></generator>
</id>
<many-to-one name="parent" class="Node">
<column name="parentid" not-null="false" />
</many-to-one>
<property name="code" type="string" column="code" not-null="false" length="50"/>
<property name="name" type="string" column="name" not-null="false" length="100"/>
<property name="type" type="string" column="type" not-null="false" length="100"/>
<map name="properties" cascade="all-delete-orphan">
<key column="nodeid" not-null="true" foreign-key="FK1cat_nodeproperties_cat_node" />
<map-key column="name" type="string" length="100" />
<one-to-many class="PropertyValue" />
</map>
</class>
</hibernate-mapping>
Node contains a map properties where key is a string and value is an entity PropertyValue.
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="it.quix.extensibility.model">
<class name="PropertyValue" table="cat_nodeproperties" lazy="false">
<id name="id" column="id" type="long" unsaved-value="0">
<generator class="increment"></generator>
</id>
<property name="type" column="type" type="string" length="15" not-null="true" />
<property name="booleanValue" column="booleanvalue" type="boolean" />
<property name="longValue" column="longvalue" type="long" />
<property name="decimalValue" column="decimalvalue" type="big_decimal" />
<property name="stringValue" column="stringvalue" type="string" length="1024"/>
<property name="dateValue" column="datevalue" type="timestamp" />
<list name="attributeList" table="cat_attribute" cascade="delete">
<key column="nodepropertiesid" not-null="true" />
<list-index column="sorting" base="1" />
<composite-element class="Attribute">
<property name="type" column="type" type="string" length="15" not-null="true" />
<property name="booleanValue" column="booleanvalue" type="boolean" />
<property name="longValue" column="longvalue" type="long" />
<property name="decimalValue" column="decimalvalue" type="big_decimal" />
<property name="stringValue" column="stringvalue" type="string" length="1024"/>
<property name="dateValue" column="datevalue" type="timestamp" />
</composite-element>
</list>
</class>
</hibernate-mapping>
I want to get all the nodes that contain the property with key ik06 and stringValue D33.
I have executed this HQL query:
Code:
from Node as n
join n.properties as prop
where index(prop) = 'ik06' and
??? prop.stringValue = 'D33' ???
but prop.stringValue is not correct.
What is the correct sintax?
Thanks,
Emanuela