-->
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.  [ 1 post ] 
Author Message
 Post subject: Union-Subclass Problem
PostPosted: Sun Sep 04, 2005 7:44 am 
Newbie

Joined: Wed Aug 27, 2003 3:47 am
Posts: 4
Location: Frankfurt, Germany
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>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.