[hibernate-issues] [Hibernate-JIRA] Created: (HHH-3301) Inconsistencies in association examples

Peter Merker (JIRA) noreply at atlassian.com
Mon May 26 15:11:33 EDT 2008


Inconsistencies in association examples
---------------------------------------

                 Key: HHH-3301
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3301
             Project: Hibernate3
          Issue Type: Improvement
          Components: documentation
         Environment: Doesn't matter
            Reporter: Peter Merker
            Priority: Minor


The examples for association mappings are inconsistent. For example, regarding bidirectional associations, it suffices to set the "unique" attribute in one of the two mapping files, as it is done in the code example for §7.5.1. The mapping file for "Address" doesn't contain any "unique" attribute (and thus can either represent a "one" or a "many" side). But in the example for §7.5.2. we see:

 <class name="Person">
    <id name="id" column="personId">
        <generator class="native"/>
    </id>
    <join table="PersonAddress"
        optional="true">
        <key column="personId"
            unique="true"/>  <!-- 1 -->
        <many-to-one name="address"
            column="addressId"
            not-null="true"
            unique="true"/>  <!-- 2 -->
    </join>
</class>

<class name="Address">
    <id name="id" column="addressId">
        <generator class="native"/>
    </id>
    <join table="PersonAddress"
        optional="true"
        inverse="true">
        <key column="addressId"
            unique="true"/>  <!-- 3 -->
        <many-to-one name="person"
            column="personId"
            not-null="true"
            unique="true"/>  <!-- 4 -->
    </join>
</class>

The occurrences marked with "3" and "4" are superfluous, I checked with hbm2ddl (adding class attributes to the many-to-ones). Even if you delete them, you always get 
"create table PersonAddress (personId integer not null unique, addressId integer not null unique, primary key (addressId));"

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       




More information about the hibernate-issues mailing list