I have two tables (Users and UserRole)
create table Users (
UserId serial not null,
UserName varchar(100) not null,
UserType varchar(15) not null,
Constraint PK_Users primary key (UserId)
)
;
CREATE TABLE UserRole
(
RoleId serial not null,
RoleType varchar(20) not null,
AccessTo varchar(100) not null,
CONSTRAINT PK_UserRoleId PRIMARY KEY (RoleId)
)
;
insert into Users (default,'Raj','Admin');
insert into Users (default,'Kumar','Internal');
insert into Users (default,'Ramesh','Internal');
insert into Users (default,'Muthu','External');
insert into Users (default,'Sundar','External');
insert into UserRole (default, 'Admin','/**');
insert into UserRole (default, 'Internal','/parking/*');
insert into UserRole (default, 'Internal','/vehciles/*');
insert into UserRole (default, 'External','/Upload/*');
insert into UserRole (default, 'External','/ViewParkings/*');
// The following join syntax doesn't work
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "UserRole",
JoinColumns(
{
JoinColumn(updatable=false,insertable=false, name="UserType"
, referencedColumnName="RoleType"),
}
private Set<UserRole> userRoles = new HashSet<userRoles>();
I am trying to establish connection between two tables without using third table (link table). Is it possible when I use hibernate?