0

如何访问用户的名字和姓氏,具体取决于显示的 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]

状态域

class Status {
  static belongsTo = [userAccount:UserAccount]
  def String statusMessage
  Date dateCreated
  Date lastUpdated
  def String statusType

政治领域

class PoliticItem {

    SystemEntity politicItemName
    UserAccount userAccount

    def String politicItemValue
    def boolean shared = false
    Date dateCreated
    Date lastUpdated

我们如何将属于所有状态的所有用户加载到政治视图中?

4

1 回答 1

1

我仍然不确定你不知道哪一部分。假设 userAccount 有 firstName 和 lastName 字段可以从状态访问它们,试试这个:

status是你的Status类的实例。您需要从中获取 userAccount 的那个。

status.userAccount.firstName

或者

status.userAccount.lastName
于 2013-06-17T17:25:10.277 回答