I have a question about collection mapping. Here is my senerio:
I have two tables:
User and
UserRole. I want to use the same two tables for user autherization and authentication in multiple applications. Therefore, the table structures are:
Code:
create table User (
user_id long,
username varchar(20),
password varchar(50),
primary key (user_id),
);
create table UserRole (
user_id long,
app_name varchar(20),
role_name varchar(20),
primary key (user_id, app_name, role_name),
);
My User object looks like this:
Code:
class User {
private long user_id;
private String username;
private String password;
private Set roles; // set of role names (string)
}
Each application will have a defined constant
APPLICATION_NAME. My question is how to map the collection
roles to the
UserRole table so that it will use
APPLICATION_NAME for the
app_name field in every CRUD action.
Any help is appreciated. Thanks!
Kenny