如何访问用户的名字和姓氏,具体取决于显示哪个statusItem是用户的子项。
class UserAccount implements Serializable {
static transients = ['pass','passConfirm','familyPicTmp', 'familyPicTmpFilename', 'photoTmp', 'photoTmpFilename']
static hasMany = [authorities: Authorisation, memberships:FamilyMembership, progenitorIwi:Family, politicItems:PoliticItem,
relationships:Relationship, , agents:UserAccount, media:UserMedia, status:Status]
static mappedBy = [ progenitorIwi:"progenitor",relationships:'relationTo', relationships:'userAccount']
static fetchMode = [memberships:FetchMode.JOIN, agents:FetchMode.JOIN]
static mapping = {
memberships(lazy:false)
agents(lazy:false)
}
static belongsTo = [Authorisation]
STATUS DOMAIN
class Status {
static belongsTo = [userAccount:UserAccount]
def String statusMessage
Date dateCreated
Date lastUpdated
def String statusType
POLITIC DOMAIN
class PoliticItem {
SystemEntity politicItemName
UserAccount userAccount
def String politicItemValue
def boolean shared = false
Date dateCreated
Date lastUpdated
我们如何将所有属于所有状态的用户加载到政治观点?
答案 0 :(得分:1)
我仍然不确定你不知道哪一部分。假设userAccount具有firstName和lastName字段以从状态访问它们,请尝试:
status
是您的Status
课程的实例。您需要从中获取userAccount的那个。
status.userAccount.firstName
或
status.userAccount.lastName