Extjs和Grails我如何防止祖先

时间:2013-01-28 10:51:18

标签: javascript grails extjs4.1

我的项目服务器站点是Grails,客户端站点是Extjs4.1,我使用关系数据库。在这种情况下我工作正常,但当我打电话给商店,然后我面临一些问题。 这个问题基于父母。当我打电话给下面的商店.....然后我必须打电话给它的父母,但我不想打电话给它的父母..

def stote(){        
    def prices = []
    Price.getAll()?.each{ v ->
        def a = v.article,
        b     = a.brand,
        bt    = b.brandType,
        gp    = b.genericProducts,
        c     = gp.categories,
        m     = b.manufacturers

        def manufacture     = [id:m.id,     name:m.name]
        def category        = [id:c.id,     name:c.name]
        def genericProduct  = [id:gp.id,    name:gp.name, m01i001001:category]
        def brandType       = [id:bt.id,    name:bt.name]
        def brand           = [id:b.id, name:b.name, m01i002001:manufacture, m01i003001:genericProduct, m01i004001:brandType]
        def article         = [id:a.id, name:a.name, mbcode:a.mbcode, pbcode:a.pbcode, details:a.details, m01i005001:brand]
        def price           = [id: v.id, m01i006001:article, price:v.price, date:v.date]
        prices << price
    }
    return prices
}

那些属于关联密钥 m01i001001,m01i002001,m01i003001,m01i004001,m01i005001,m01i006001

我的所有人喜欢

 belongsTo : [{
  model          : '${pkgName}.M01I005001',
  associatedName : 'M01I005001' ,
  associationKey : 'm01i005001' , 
  primaryKey     : 'id' , 
  foreignKey     : 'brandId'     
}],

我想像这家店一样打电话......

def stote(){        
    def prices = []
    Price.getAll()?.each{ v ->
        def a = v.article

        def article         = [id:a.id, name:a.name, mbcode:a.mbcode, pbcode:a.pbcode, details:a.details]
        def price           = [id: v.id, m01i006001:article, price:v.price, date:v.date]
        prices << price
    }
    return prices
}

但是当我调用这个商店然后客户端加载问题。我不能懒惰它的父母。它的节目总是渴望。

如果您有任何想法可以解决此错误,请与我们联系。

提前致谢

1 个答案:

答案 0 :(得分:1)

这不是解决方案。我为此创建了一个代理模型,我删除了所有不必要的关系,然后我解决了我的问题,这意味着我只保留一个所有者,所以只保留一个关联密钥。