-->
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: Table per subclass & unidirectional one-to-many, 3.5.2-Final
PostPosted: Mon May 31, 2010 7:29 am 
Newbie

Joined: Mon May 31, 2010 6:24 am
Posts: 1
Hello!


What I have
I have a class called Node, and, two classes that are joined subclasses, extending it, called Part, and Form.

Associations
Part has a unidirectional one-to-many association on a join table. The join table maps Parts with Nodes.
Cascade all is specified.

What invokes the problem
  • I create a Part, then add a Form to it.
  • I run
    Code:
    session.saveOrUpdate(part)
    to save the Part instance.

I notice clearly that both the Part and the Form are persisted. But...

The problem
I don't fint that the join table is populated!


Why is this?


There are no exceptions!

I'd like to use a unidirectional one-to-many association, because there is optional multiplicity on the child's behalf.

I use Hibernate version 3.5.2-Final!


Code
Mapping for class Node:
Code:
<hibernate-mapping>
    <class name="com.company.project.domain.configurator.Node" table="NODE">
        <id name="id" type="java.lang.Integer">
            <column name="NODE_ID" />
            <generator class="native" />
        </id>
        <version name="version" />
        <property name="name" type="java.lang.String">
            <column name="NAME" />
        </property>
        <property name="label" type="java.lang.String">
            <column name="LABEL" />
        </property>
    </class>
</hibernate-mapping>
</code>


Mapping for class Part:
Code:
<hibernate-mapping>
    <joined-subclass
name="com.company.project.domain.configurator.Part"
extends="com.company.project.domain.configurator.Node"
    table="PART" lazy="false">
        <key>
            <column name="NODE_ID" />
        </key>
        <set name="nodes" table="PART_NODE" cascade="all">
            <key>
                <column name="PART_ID" />
            </key>
            <many-to-many column="NODE_ID" unique="true"
class="com.company.project.domain.configurator.Node"/>
        </set>
    </joined-subclass>
</hibernate-mapping>


Mapping for class Form:
Code:
<hibernate-mapping>
    <joined-subclass
name="com.company.project.domain.configurator.Form"
extends="com.company.project.domain.configurator.Node"
    table="FORM" lazy="false">
        <key>
            <column name="NODE_ID" />
        </key>
    </joined-subclass>
</hibernate-mapping>


Thank you very much in advance!

This is very important for me. I will grant you 110 Karma points, perhaps even more for answering this.

The supple and most docile,


Leif Bork


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.