-->
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.  [ 4 posts ] 
Author Message
 Post subject: Error in Hibernate Reference?
PostPosted: Mon May 26, 2008 5:36 am 
Beginner
Beginner

Joined: Mon Jul 23, 2007 12:37 pm
Posts: 24
Well, doesn't really seem to be an error, but wouldn't it be more coherent if the listing §7.5.1, which reads now

Code:
...
    <join table="PersonAddress"
        inverse="true"
        optional="true">
        <key column="addressId"/>
        <many-to-one name="person"
            column="personId"
            not-null="true"/>
    </join>
</class>

would be rewritten to

Code:
...
    <join table="PersonAddress"
        inverse="true"
        optional="true">
        <key column="addressId"
            unique="true"/>  <!-- !!! -->
        <many-to-one name="person"
            column="personId"
            not-null="true"/>
    </join>
</class>
?
The unique attribute makes sense and is used for key columns in other join table examples, e.g. §7.3.2 and §7.5.2. I guess the correction would make things more coherent and thus more understandable.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 26, 2008 9:52 am 
Beginner
Beginner

Joined: Mon Jul 23, 2007 12:37 pm
Posts: 24
Just noticed that the unique keyword is only used for constraint definition. As the unique constraint on the addressId column is already defined in the mapping for Person, it doesn't need to be mentioned again in the Address mapping. OK, please forget my previous posting :-)


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 26, 2008 10:10 am 
Beginner
Beginner

Joined: Mon Jul 23, 2007 12:37 pm
Posts: 24
But then again, why does §7.5.2 look like this

Code:
<class name="Person">
    <id name="id" column="personId">
        <generator class="native"/>
    </id>
    <join table="PersonAddress"
        optional="true">
        <key column="personId"
            unique="true"/>  <!-- !!! -->
        <many-to-one name="address"
            column="addressId"
            not-null="true"
            unique="true"/>  <!-- !!! -->
    </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"/>  <!-- !!! -->
        <many-to-one name="person"
            column="personId"
            not-null="true"
            unique="true"/>  <!-- !!! -->
    </join>
</class>

?
unique is mentioned for each of the two columns (so you get a one-to-one), but in both class mappings! Shouldn't it only be mentioned in the Person mapping, so that the join table element in Address would just look like the one in §7.5.1. ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 26, 2008 3:12 pm 
Beginner
Beginner

Joined: Mon Jul 23, 2007 12:37 pm
Posts: 24
I created a bug report for this: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3301


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.