hallo alltogether,
until now I have found how to map a many2many-relationship between to tabels "s" and "d" with the third table "map". Normaly you will use the tweo foreign key as tablekey for map. But in the legacy database I work with the map table also has a own primary key. How to map this without a own Java entity?
@Entity
@Table(name="s")
public class Src {
@Id
@Column(name="s_id")
int getId() { ... }
@ManyToMany
@JoinTable(name="map",
joinColumns={@JoinColumn(name="s_key")},
inverseJoinColumns={@JoinColumn(name="d_key")})
Collection<Dst> getChildren() { ... }
}
@Entity
@Table(name="d")
public class Dst {
@Id
@Column(name="d_id")
int getId() { ... }
}
The relationship has no additional information and must be mapped only at one side of the relationship.
The database structure couldn't be changed.
thakyou for any hint
Sunshine08
|