Question

i am using user role relationship using hibernate that is available on so many websites.
But In my case user table already having users and roles table also having all the predefined roles.

Now what i want is to fetch all the available roles from roles table and check box as "checked" if it is available to the given user_id in third table(user_role).

Was it helpful?

Solution

You have to make your Entity classes to use exist tables and columns names using name attribute in @Table and @Column, then the relation will be @OneToMany at user entity to the authorities entity with for ex Set<Role>, then in view you can make your check to know if this user have a specific role or not.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top