aspose file tools*
The moose likes Object Relational Mapping and the fly likes Multiplicity & not-null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Multiplicity & not-null" Watch "Multiplicity & not-null" New topic
Author

Multiplicity & not-null

Vivek Alampally
Ranch Hand

Joined: Jul 10, 2008
Posts: 67
If in <many-to-one>, not-null=true what does that mean? Foreign key column cannot take null values or can take null values.
My prediction is it can take null values. It is used when 0..1/0..* multiplicity is there

And, if an association is there between A & B with A's multipicity 1..1 and B's multiplicity is 1..* , Then in database(Create statement) or in Hibernate mapping file(B.hbm.xml) how can B's multipicity with A is represented?
And, if B's multiplicity is 0..* How is this represented?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


If in <many-to-one>, not-null=true what does that mean? Foreign key column cannot take null values or can take null values.
My prediction is it can take null values. It is used when 0..1/0..* multiplicity is there

No, it s the opposite. You are right the not-null attribute is a direction for the schema creation stuff in Hibernate. not-null == true means the foreign key column cannot be null (i.e. the multiplicity of the relationship os 1..*).


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Vivek Alampally
Ranch Hand

Joined: Jul 10, 2008
Posts: 67
Thanks Paul. I was confused because in "Hibernate in action" in chapter 3 while explaining a relationship between Item and Bid. The author marked
not-null=true for 0..* multiplicity. So it should be false right!!! for 0..* multiplicity.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multiplicity & not-null