-->
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.  [ 2 posts ] 
Author Message
 Post subject: list with join table, but join table is not created
PostPosted: Tue May 17, 2005 6:07 pm 
Newbie

Joined: Tue Apr 12, 2005 6:00 pm
Posts: 4
I've got a one-to-many unidirectional mapping:

Code:
<class name="OrgPage">
    <id name="id">
        <generator class="native"/>
    </id>
    <list name="links" table="linksToOrgPage" cascade="all-delete-orphan">
        <key column="linkId"/>
        <index column="position"/>
        <one-to-many class="Link"/>
    </list>
</class>

<class name="Link" table="links">
    <id name="id">
        <generator class="native"/>
    </id>
    <property name="url"/>
    <property name="text"/>
    <property name="description"/>
</class>


Not sure why, but instead of creating a join-table, position and linkId are added to the links table:

Code:
mysql> desc links;
+-------------+--------------+------+-----+---------+----------------+
| Field       | Type         | Null | Key | Default | Extra          |
+-------------+--------------+------+-----+---------+----------------+
| id          | bigint(20)   |      | PRI | NULL    | auto_increment |
| url         | varchar(255) | YES  |     | NULL    |                |
| text        | varchar(255) | YES  |     | NULL    |                |
| description | varchar(255) | YES  |     | NULL    |                |
| linkId      | bigint(20)   | YES  | MUL | NULL    |                |
| position    | int(11)      | YES  |     | NULL    |                |
+-------------+--------------+------+-----+---------+----------------+


Does anyone see what's wrong with this mapping?


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 17, 2005 6:48 pm 
Newbie

Joined: Mon Jun 07, 2004 9:18 am
Posts: 13
Location: Torino, Italy
The documentation says that for one-to-many association, the table attribute is ignored.
In fact you don't need an extra table to map a <list> in one-to-many relation, but only in many-to-many.
The field position is added to table links because it represent the index of the list.
The field linkId is IMHO misnamed, I would call it orgPageId, since it represent the pointer to the OrgPage for each Link element.

Simon


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

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.