Win a copy of liveProject: Protecting User Data with Spring Security and OAuth2 this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Possible to find relationship

 
Ranch Hand
Posts: 856
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 856
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic