Is it possible to define a collection of dynamic components when running in dynamic-map mode?
I am running with:
<property name="hibernate.default_entity_mode">dynamic-map</property>
and am trying to work out how to set a collection of dynamic components.
With the following mapping file below the composite-element tag requires a class but hibernate does not accept java.util.Map as a class saying that it cannot introspect and find the setters:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class entity-name="Pump" table="Pump"
lazy="true">
<tuplizer entity-mode="dynamic-map"
class="org.hibernate.tuple.entity.MyCustomTuplizer" />
<id name="id" type="long" column="ID">
<generator class="native" />
</id>
<property name="serialNumber" type="string" />
<set name="billOfMaterials" table="BillOfMaterials" lazy="true">
<key column="id" />
<composite-element class="java.util.Map">
<property name="partName" />
<property name="quantity" />
</composite-element>
</set>
</class>
</hibernate-mapping>
I was looking for something like the following but clearly there is no such thing as <dynamic-composite-element>:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class entity-name="Pump" table="Pump"
lazy="true">
<tuplizer entity-mode="dynamic-map"
class="org.hibernate.tuple.entity.MyCustomTuplizer" />
<id name="id" type="long" column="ID">
<generator class="native" />
</id>
<property name="serialNumber" type="string" />
<set name="billOfMaterials" table="BillOfMaterials" lazy="true">
<dynamic-composite-element>
<property name="partName" />
<property name="quantity" />
</dynamic-composite-element>
</set>
</class>
</hibernate-mapping>
Is there a way to have a collection of dynamic composite parts or do I have to turn the composite into a dynamic-map entity and set cascade to the relationship?
thx