I have the following preexisting tables inside a MySQL 5 database:
The relationship(s) are mapped to the User_App_Bridge table (as the name implies, a bridge) amongst App and User as a One to Many cardinality.
The E-R diagram:
User ------ User_App_Bridge------ App
1 User is associated with many apps inside the User_App_Bridge table.
1 App is associated with many users inside the User_App_Bridge table.
The DDL for the User_App_Bridge table:
Lets say that I have the following JPA Annotated Classes which are mapped to these tables:
(1) Is this (the block inside the @JoinTable) the correct way to do the one to many mapping for User and App entites with the UserAppBridge?
(2) Inside the @JoinTable should the column & referencedColumnName be assigned to the SQL value (e.g. name="User_Id" , referencedColumnName = "User_Id")
or should it be the Java reference name (e.g. name="userId" , referencedColumnName = "userId")?
(3) Inside the inverseJoinColumns code black, is the unique = true necessary (what is it for)?
(4) Do I need to do anything else inside the UserAppBridge class (for connecting to App and User)?