• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Possible to find relationship

 
Amandeep Singh
Ranch Hand
Posts: 850
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried @OneToOne, @ManyToOne, @OneToMany and @ManyToMany relaltionships.

And the table's are made successfully. But now my question is, when i look at the table's in database, i can't differntiate whether these table's has which association mean's i can't recognize out of these @OneToOne, @ManyToOne, @OneToMany and @ManyToMany relaltionships, is for which table from database look.
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@OneToOne relationship is implemented in different ways
1- sharing the primary key
2- you find, a relation like
table citizen has citizenship column (BLOB) that is a java class for you.

@OneTOMany relationship is implemented with foreign key reference, for
instance. SO you can easily look for foreign key constraint

@ManyToMany relationship is implemented using third intermediary table. You
can find two referencing column (that joins two relations) in this third
intermediary table.
 
Chaminda Amarasinghe
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think above explanation is not correct if you generated tables. (Im not 100% sure)

I think in all cases It will create join table if you didnt specify joinColumn

for an example


Owner

@o2o
Child child


Child

@o2o
Owner owner



So for above table structure provider will create Owner, Child tables + ADDITIONAL Owner_Child table having owner_id and child_id columns.
 
Amandeep Singh
Ranch Hand
Posts: 850
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So can i conclude that, it's not possible to find out the relationship differnce between @OneToOne uni-directional and @OneToOne bidirectional, when i look in the database.
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chaminda/ Amandeep

I have this example, does it adhere what I said in my earlier post:






And I got following generated table schema:

[ November 26, 2008: Message edited by: Chandra Bhatt ]
 
Chaminda Amarasinghe
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As i pointed in my last post, here you have used joincolumn so this is a correct implementation and adhere to your earlier post
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic