• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

@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: 42135
937
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: 42135
937
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic