I have the following domains: User, Role, Company. User and Role has m:n relationship, Company to User has 1:m, and User to Company is 1:1. I'm having problem with the definition of User domain. Here it is:
class User {
static hasMany = [authorities: Role ]
static belongsTo = [ Role , Company ]
}
I would like to access the company from a User so that user.company will give me the company where he is assigned. This modification is not allowed:
static belongsTo = [ Role , company: Company ]
Here's the error:
Unexpected node type: EXPR found when expecting type: LABELED_ARG at line: 9 column: 41. File: /Users/alfred/Applications/grails_projects/extramile/grails-app/domain/fbm/extramile/User.groovy @ line 9, column 41.
Note that it is not an option to also do this:
static belongsTo = [ role: Role , company: Company ]
Since User-Role has m:n (also specified by the 'authorities' variable already).
Any other workaround? Thanks.