0

GORM と Grails でのドメイン オブジェクトのモデリングに関する知識が乏しいため、問題が発生します。

ここに私の問題があります:

| Error Error loading plugin manager: 
No owner defined between domain classes [class com.myproject.model.Project] and 
[class com.crowdfun.Sector] in a many-to-many relationship. 
Example: static belongsTo = com.myproject.model.Sector 
(Use --stacktrace to see the full trace)

公式の grails ドキュメントのチュートリアルに従っているため、何が問題なのかはわかりません: http://grails.org/doc/latest/guide/GORM.html#manyToMany

私のクラス:

Project.groovy :

class Project {

    String name
    Integer nbInvestors
    Region region
    Integer nbDays
    Boolean success
    String equity
    String currency
    Double target
    Double raisedAmount
    String url
    Double valuation

    boolean extended = false

    static belongsTo = [
        site: Site,
        sector: Sector
    ]

    static hasMany = [
        sectors: Sector
    ]

    static hasOne = [
        valuationRange: ValuationRange,
        targetRange: TargetRange
    ]

    static constraints = {
        name nullable: true
        nbInvestors nullable: true
        region nullable: true
        nbDays nullable: true
        success nullable: true
        equity nullable: true
        currency nullable: true
        target nullable: true
        raisedAmount nullable: true
        url nullable: true, unique: true
        valuation nullable: true
    }
}

Sector.groovy :

class Sector {

    String name

    static hasMany = [
        projects: Project
    ]

    static constraints = {
        name unique: true
    }

    @Override
    public String toString() {
        return name
    }

    def getNbProjects() {
        projects.size()
    }
}

Site.groovy

class Site {

    String name

    static hasMany = [
        projects: Project
    ]

    static constraints = {
        name unique: true
    }

    @Override
    public String toString() {
        return name
    }
}
4

1 に答える 1

1

クラスを次のように変更します。

class Project {

    ...
    Site site
    Sector sector

    static belongsTo = [Site, Sector]
}
于 2013-11-05T13:13:32.047 に答える