Thank you for your reply!
My problem turned out to be my incomplete knowledge of Hibernate and to use correct terminology.
Rewording my problem statement:
I have numerous 1:1 class:data-table mappings.
In my database I have numerous
association-tables linking the various data-tables.
I need to incorporate these association tables into my app somehow
Solution was easy ( after RT*Ming a bit more ):
Association tables are commonly refered to as join tables
for a given association table:
in each class referenced by the association table, add a field corresponding to the OTHER class
and map using @JoinTable
Example:
given an association table District_User_Relationship containing two fields
id_user bigint,
id_district bigint
with a many:many relationship
and classes User and District mapped to data tables Users and Districts respectively
Code:
@Entity
@Table(name="Districts")
public class District
{
@Id
private Long id;
.....
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name="District_User_Relationship",
joinColumns={ @JoinColumn(name="id_district") },
inverseJoinColumns={ @JoinColumn(name="id_user") }
)
private Set<User> users;
and
Code:
@Entity
@Table(name="Users")
public class User
{
@Id
private Long id;
.....
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name="District_User_Relationship",
joinColumns={ @JoinColumn(name="id_user") },
inverseJoinColumns={ @JoinColumn(name="id_district") }
)
private Set<District> districts;
Important note: you do NOT add any references to the association table in any Hibernate stuff ( hibernate.cfg.xml, HibernateUtils, create any DAO stuff, etc)
Hope this helps others.
Thx,
Still-learning Steve