• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

How to represent JPA @OneToMany for Two Many Tables?

 
Bartender
Posts: 1899
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you have a "1" table that is 1:M with two tables, how do you represent that in JPA @OneToMany Annotation?

If I try to have two @OneToMany annotations in my "1" side Java class, I get an duplicate annotation error.

So, what I'm asking is that if you have some type of, say, "ID" (from the 1 table) that can appear multiple times in two (different) tables, how do you represent this with a single @OneToMany annotation on the "1" side?

Thanks in advance for any suggestions!

- Mike
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't completely understand what you are trying to do.

Do you want the result sets from two unique tables to be merged into a single result set?

-Shannon
 
Mike London
Bartender
Posts: 1899
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think my problem was that I had the relationship backwards. We're doing forward engineering with no DB (yet) to test against so it's a bit more difficult...

Thanks.

-- Mike
 
Shannon McGee
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No problem!

Glad you got things squared away.
 
I've got no option but to sell you all for scientific experiments. Or a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic