-->
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.  [ 11 posts ] 
Author Message
 Post subject: Meaning of inverse=true
PostPosted: Thu Nov 20, 2003 6:58 am 
Beginner
Beginner

Joined: Thu Oct 02, 2003 8:02 am
Posts: 45
I have a class Utilisateur and class Evenement with a one-to-many association with the following code :

Code:
class Utilisateur
{
      //...
      Set evenements;
      //...
}

class Evenement
{
      //...
      Utilisateur user;
}


The mapping file is :
<class name="com.cfort.calendrier.Evenement" table="evenement">
<id name="id" column="id">
<generator class="hilo"/>
</id>
<property name="moment" type="string" length="12"/>
<property name="debut" type="string" length="10"/>
<property name="fin" type="string" length="10"/>
<property name="titre" type="string" length="40"/>
<property name="description" type="string" length="200"/>
</class>
<class name="com.cfort.utilisateur.Utilisateur" table="utilisateur" >
<id name="identifiant" column="identifiant" type="string" length="20">
<generator class="assigned"/>
</id>
<property name="dateAbonnement" type="date"/>
<property name="datePaiement" type="date"/>
<property name="modeReglement">
<column name="modeReglement" sql-type="varchar(30)"/>
</property>
<property name="nbPoints" type="integer"/>
<set name="evenements">
<key column="utilisateur_numero"/>
<one-to-many class="com.cfort.calendrier.Evenement"/>
</set>

</class>

What does it mean if i modify the code in the mapping file by :
<set name="evenements" inverse="true">
<key column="utilisateur_numero"/>
<one-to-many class="com.cfort.calendrier.Evenement"/>
</set>


I read the documentation but i don't understand the explanations of inverse="true"

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 20, 2003 7:27 am 
Senior
Senior

Joined: Tue Oct 21, 2003 8:15 am
Posts: 186
Quote:
I read the documentation but i don't understand the explanations of inverse="true"


Most people don't

Quote:
What does it mean if i modify the code in the mapping file by :


I guess it means you can't persistently add Utilisateur's to evenements.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 20, 2003 7:30 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
No, _you_ don't. The other 20.000 do.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 20, 2003 8:09 am 
Senior
Senior

Joined: Tue Oct 21, 2003 8:15 am
Posts: 186
Quote:
No, _you_ don't. The other 20.000 do.


Well, with flam70 we're two. And I'm pretty sure the other 20.000 was confused too.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 20, 2003 8:11 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
http://www.hibernate.org/Documentation/ ... nverseTrue

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 20, 2003 8:42 am 
Senior
Senior

Joined: Tue Oct 21, 2003 8:15 am
Posts: 186
Quote:
inserts work fine because I set <many-to-one not-null="true"


non-null="true" means the column cannot be null, right?

-----------------

Nice article! But a few points to fix:

Quote:
The side having inverse="false" (default value) has this responsability...


Typo.

Quote:
This is not recommanded.


Typo.

Quote:
is set during the child save : this is of the child responsability.


Typo.

Quote:
This is not recommanded.


Typo.

Quote:
This is ineficient considering


Typo.

Quote:
But I avoid it for sample purpose.


What's a sample purpose?

Quote:
after this tutorial, I will be soooo easy ;-)


Good to hear that you will be soooo easy ;-)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 20, 2003 8:44 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You realize there is an "EDIT" button on the top of this page?

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 20, 2003 8:49 am 
Senior
Senior

Joined: Tue Oct 21, 2003 8:15 am
Posts: 186
No, there's no EDIT button. If it were - I'd click it.

And yes, I'm logged in.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 20, 2003 9:26 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
nickvajberg wrote:
Quote:
inserts work fine because I set <many-to-one not-null="true"


non-null="true" means the column cannot be null, right?

You're right. Actually I'm not sure this attribute is used by the core of hibernate (only tools ?). And I may be wrong guessing hibernate needs not-null on many-to-one to insert in the proper order. Experts needed.

nickvajberg wrote:
Nice article! But a few points to fix

Well thanks, you were the guy who pushed me to write it ;-)
I'm not a native English speaker, it explains the typos : I fixed then.

nickvajberg wrote:
Quote:
But I avoid it for sample purpose.

What's a sample purpose?


I changed to : I didn't do it to keep this explanation easier to understand and avoid concepts mismatch.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 20, 2003 10:54 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Quote:
Well thanks, you were the guy who pushed me to write it ;-)



Dude, you are an absolute hero, for doing stuff like this and for helping out so much in the forum at the moment. We really appreciate your efforts.

peace

Gavin


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 20, 2003 1:36 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
gavin wrote:
We really appreciate your efforts.

Thanks, I appreciate.
Keep improving this fabulous tool and I'll be happy ;-)

_________________
Emmanuel


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