Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

@OneToMany new reference table is generated.

 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • 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: 40169
812
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Jeanne,

Below is the code I used:







persistence.xml


Thanks
 
Jeanne Boyarsky
author & internet detective
Posts: 40169
812
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
thanks Jeanne
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. 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
    Bookmark Topic Watch Topic
  • New Topic