-->
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: Best approach for specific many-to-many mapping?
PostPosted: Sun May 09, 2004 10:00 pm 
Newbie

Joined: Thu May 06, 2004 11:08 pm
Posts: 3
Location: Australia
Hi,

I am trying to model a camp ground, with Camp Sites adjacent to each other. It took me a little while to realise this is actually a many-to-many mapping. I amended my mappings and everything now seems fine, or at least acceptable. But is occurs to me that I really would like to read the mapping table transitively, that is, if site 5 is recorded as adjacent to site 10, then that mapping should act as also declaring 10 adjacent to 5.

Currently, my mapping file contains:
Code:

<hibernate-mapping>
    <class
        name="au.com.objectconsulting.camping.model.Site"
        table="site"
        dynamic-update="false"
        dynamic-insert="false"
    >

        <id
            name="id"
            column="id"
            type="java.lang.Long"
        >
            <generator class="native">
            </generator>
        </id>

        <bag
            name="adjacentSites"
            table="adjacent_sites"
            lazy="true"
            inverse="false"
            cascade="none"
        >

              <key
                  column="site_id"
              />

              <many-to-many
                  class="au.com.objectconsulting.camping.model.Site"
                  column="adjacent_id"
                  outer-join="auto"
              />

        </bag>



Which results in the table definition:
Code:
create table adjacent_sites (site_id BIGINT not null, adjacent_id BIGINT not null)


Which means each pair of adjactent sites should be recorded twice and enforged by coded businsess logic rules. Is there any way to read the mapping table both ways?

Regards
Peter Miller


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.