0

I need to create a connection with a table that isn't in my control yet there's a one-to-many relationship so I'm having a bit of trouble with the hibernate mappings.

table1:

userId
firstname
lastname

table2:

user_id <= fk to table1.userId 
x_id
create_date

table3:

x_id
private1
private2

So my problem is that despite it being a one-to-many in reality I'll probably have to map it as a many-to-many. And a problem is that one of the column names in table 2 doesn't match the column name it references to in table 1. An additional problem I have is that in table 2 user_id and x_id form a combined primary key.

So far I've been using Hibernate mapping files and not annotations. And I'd like to use an arraylist.

halfer
  • 19,824
  • 17
  • 99
  • 186
jack
  • 1,902
  • 5
  • 32
  • 43

1 Answers1

0

If i understand you correctly, you should map it as many to many relation using composite primary key.

Please see carefully ll the answers and questions on those posts it will help you.

Mapping same class relation

and then

Mapping same class relation - continuation

I think it have all the answers inside.

Community
  • 1
  • 1
danny.lesnik
  • 18,479
  • 29
  • 135
  • 200