• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to represent JPA @OneToMany for Two Many Tables?

 
Mike London
Ranch Hand
Posts: 1227
6
  • Mark post as helpful
  • send pies
  • 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
 
Shannon McGee
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • 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
Ranch Hand
Posts: 1227
6
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
No problem!

Glad you got things squared away.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic