• 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
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

@OneToMany new reference table is generated.

 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have OrderMain table and OrderItems tables with @OneToMany relationship in them. I set table schema to be generated automatically.
It generates a third reference table named OrderMain_OrderItems containing id from the OrderMain and OrderItems.
I wanted to have the Foreign Key to be there in OrderItems table referring OrderMain table id (PK).
Is there any setting to avoid the third referencing table and have the FK on the target side of the relationship.


 
author & internet detective
Posts: 40669
827
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chandra,
Can you show the code? What you describe makes sense for a many to many relationship. I'm surprised to see it for a one to many.
 
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
Jeanne,

Below is the code I used:







persistence.xml


Thanks
 
Jeanne Boyarsky
author & internet detective
Posts: 40669
827
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chandra,
Usually when I create a @OneToMany relationship, it is bi-directional. This would mean Order_Items would point to Order_Main.

The TopLink documentation says "configure the details of the join table used by TopLink JPA for uni-directional one-to-many relationships". Maybe the join table is being created in your example because Order_Main isn't being told which table Order_Items is in?
 
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
thanks Jeanne
 
If you want to look young and thin, hang around old, fat people. Or this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic