-->
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: Hibetnate mappings for one-to-many and many-to-one
PostPosted: Sat Jan 04, 2014 4:44 pm 
Newbie

Joined: Mon Oct 21, 2013 5:32 pm
Posts: 8
I am new to Hibernate and learning Hibernate using the hibernate documentation (http://docs.jboss.org/hibernate/orm/3.3/reference/en-US/html/associations.html#assoc-unidirectional-12m) and going through the one-to-many and many-to-one associations without using Join tables. The document says that:

Many-to-One

A unidirectional many-to-one association is the most common kind of unidirectional association.

One-to-Many

A unidirectional one-to-many association on a foreign key is an unusual case, and is not recommended.

Why the document recommends not use one-to-many associations? Please help me in understanding this?

Also the document says that the association for many-to-one with join table is used when the association is optional. What does it mean when it says the association is optional?

Many-to-one

A unidirectional many-to-one association on a join table is common when the association is optional.

Please help me in understanding the concepts.


Top
 Profile  
 
 Post subject: Re: Hibetnate mappings for one-to-many and many-to-one
PostPosted: Mon Jan 06, 2014 3:14 pm 
Newbie

Joined: Mon Jan 06, 2014 3:12 pm
Posts: 1
chaitanya_r wrote:
I am new to Hibernate and learning Hibernate using the hibernate documentation (http://docs.jboss.org/hibernate/orm/3.3/reference/en-US/html/associations.html#assoc-unidirectional-12m) and going through the one-to-many and many-to-one associations without using Join tables. The document says that:

Many-to-One

A unidirectional many-to-one association is the most common kind of unidirectional association.

One-to-Many

A unidirectional one-to-many association on a foreign key is an unusual case, and is not recommended.

Why the document recommends not use one-to-many associations? Please help me in understanding this?

Also the document says that the association for many-to-one with join table is used when the association is optional. What does it mean when it says the association is optional?

Many-to-one

A unidirectional many-to-one association on a join table is common when the association is optional.

Please help me in understanding the concepts.


Thanks for your post, I could use assistance here as well. What is the comment that association is optional refer to? I'm lost there. thank you.


Top
 Profile  
 
 Post subject: Re: Hibetnate mappings for one-to-many and many-to-one
PostPosted: Tue Jan 07, 2014 8:51 am 
Newbie

Joined: Mon Oct 21, 2013 5:32 pm
Posts: 8
Hi, are you asking me the same question back to me which I don't know or you want to give an answer for my post?


Top
 Profile  
 
 Post subject: Re: Hibetnate mappings for one-to-many and many-to-one
PostPosted: Tue Jan 07, 2014 1:55 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
"optional" in this context means that the entity might be associated with null.

You have to declare if that is a valid relation or not, as the mapping to the database schema depends on it.

_________________
Sanne
http://in.relation.to/


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.