• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

How to represent JPA @OneToMany for Two Many Tables?

 
Bartender
Posts: 1973
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: 1973
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.
 
Looky! I'm being abducted by space aliens! Me and this tiny ad!
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic