spring - Getting list of user authorities returns empty list on root/index request mapping after logging in -


i have following request mapping used index page of app upon logging in. have argument resolver person type gives me me logged in user. while running in debug, can inspect currentuser , see user's authorities, resulting authorities collection empty when it's added model. i'm kind of scratching head why. i'm using jpa user's information database.

@requestmapping(value = "/", method = requestmethod.get) public string index(model model, person currentuser) {     collection<string> authorities = currentuser.getauthorities().stream().map(grantedapplication::getauthority).collect(collectors.tolist());     model.addattribute("authorities", authorities);     return "index"; } 

so turns out on person type, needed set fetching eager on authorities , works...

before

@onetomany @joincolumn(name = "uacode", referencedcolumnname = "usrcode") private collection<grantedapplication> authorities; 

after

@onetomany(fetch = fetchtype.eager) @joincolumn(name = "uacode", referencedcolumnname = "usrcode") private collection<grantedapplication> authorities; 

Comments