hi all
i have 3 tables and want to get them in relationship within one table:
following structure describes my problem:
Code:
table vehicle
--------------
v_id | name
--------------
1 | car
2 | boat
Code:
table part
--------------
p_id | name
--------------
1 | door
2 | seats
3 | buttons
Code:
table color
--------------
c_id | color
--------------
1 | green
2 | blue
3 | red
Each vehicle could have several (vehicle)parts with different colors. so i want to get them in a manytomany relationship like:Code:
table group
---------------------
v_id | p_id | c_id
---------------------
1 | 1 | 1
1 | 2 | 1
1 | 3 | 2
i know how to get 2 Tables (Beans) in a manytomany relationship.
Bean vehicle:
----------
Code:
@ManyToMany
@JoinTable(
name = "groupTable",
joinColumns = {@JoinColumn(name = "v_id")},
inverseJoinColumns = {@JoinColumn(name = "p_id")}
)
private Set<Part> p= new HashSet<Part>();
Bean part:
-----------
Code:
@ManyToMany(mappedBy = "part")
private Set<Vehicle> v= new HashSet<Vehicle>();
But how could i get 3 tables (also Bean color) in a manytomany relationship?
All help would be great appreciated.
thank you in advance!!
maxpade