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: Many-to-many mapping to itself
PostPosted: Wed Aug 26, 2009 8:42 am 
Newbie

Joined: Wed Aug 26, 2009 8:35 am
Posts: 1
Hi, first time here so bear with me! I had a working many-to-many relation, that needed changing to two one-to-many relations. I've done this successfully in 2 other parts of my program, but this third is causing me trouble. The problem is that the class is relating to itself.

Setup:

CDDefinition: contains a set of CDReferences
CDReference: contains 2 CDDefinition's with different names

Since CDReference must relate to the primary key of CDDefinition, it ends up with having two many-to-one mappings using the same column, which causes issues.

Hope thats clear enough! Any insight or information would be appreciated.

David

.hbm.xml files

Code:
<hibernate-mapping package="openmath.model">
    <class name="CDReference" table="cdreferences">
        <id name="id" column="ref_id">
            <generator class="increment"/>
        </id>
        <version name="version" column="version"/>
        <many-to-one name="from" column="def_id" insert="false" update="false"/>
        <many-to-one name="to" column="def_id" insert="false" update="false"/>
    </class>
</hibernate-mapping>

<hibernate-mapping package="openmath.model">
    <class name="CDDefinition" table="cddefinitions">
        <id name="id" column="def_id">
            <generator class="increment"/>
        </id>
        <version name="version" column="version"/>
        ...
        <set name="references">
            <key column="def_id"/>
            <one-to-many class="CDReference"/>
        </set>
     </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.