reset password
Author Message
Posts: 57
Posted 23:04 Jul 22, 2015 |

Dr. Sun, I'm using your model for HW4 and there's the code below for the user role:

    @CollectionTable(name = "authorities", joinColumns = @JoinColumn(name = "user_id"))
    @Column(name = "role")
    private Set<String> roles;


    public User() {
        roles = new HashSet<String>();

    public boolean isAdmin() {
        return roles.contains("ROLE_ADMIN");

    public boolean isReviewer() {
        return roles.contains("ROLE_REVIEWER");

I've populated the "authorities" table with user ID and role name, such as (1, 'ROLE_ADMIN'). But when I try to access an admin user's role using the isAdmin() method, it returned a 'false'. Can you give a hint on how to correctly identify the role of a user?

Posts: 2935
Posted 07:32 Jul 23, 2015 |

Just debug.