Hi,
I am currently facing an oddity which I can not explain to be a misunderstanding, a misusage, a misconfiguration or a bug. I have a class "Node" and a class "Edge". The Node has a list of edges of type Edge. Each Edge has a reference to a source node and a sink node. Everything just works fine.
Now here is my problem: I subclass edge to NamedEdge and do a union-sublcass mapping in the Edge mapping. If I add an instance of NamedEdge to the list in an instance of node, I receive an error something like "batch update expected 1 lines to be updated or inserted but 0 have been" once I do a session.save(node). If I look at the hibernate sql it tries to update the table EDGE, where it should update the table NAMEEDGE, but it seems to insert data in NAMEDEDGE.
Can I not - even if I have a subclass defined in the mapping - add instances of that subclass to a list of node? Should I not be able to?
If needed I have written a hibernate testcase for 3.0.5 for this and can provided by mail.
the mapping file:
<?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="org.hibernate.test.unionsubclassderived">
<class name="Node" table="NODE">
<id name="id" unsaved-value="0" column="ID">
<generator class="increment"/>
</id>
<bag name="edges" cascade="all">
<key column="node_source_id"/>
<one-to-many class="Edge"/>
</bag>
</class>
<class name="Edge" table="EDGE">
<id name="id" unsaved-value="0" column="ID">
<generator class="increment"/>
</id>
<many-to-one name="source" column="node_source_id" class="Node" cascade="all"/>
<many-to-one name="sink" column="node_sink_id" class="Node" cascade="all"/>
<union-subclass name="NamedEdge" table="NAMEDEDGE">
<property name="name" />
</union-subclass>
</class>
</hibernate-mapping>
|