allthenutsandbolts
allthenutsandbolts

Reputation: 1523

Missing Column Id

I reverse engineered a database to Domain classes. When I try to run the app, I get an error

Missing Colum : tbl_fiscal_year_id in tblAccessRight.

The Definition and mappings for the Domain classes are as follows

class TblAccessRight {    
    long  rightID
    Character code
    String name
    Boolean active
    TblFiscalYear tblFiscalYear

    static hasMany = [tblPrivileges: TblPrivilege,
                      tblResourceTypes: TblResourceType]

    static mapping = {
        id column: "RightID", generator: "assigned",name:'rightID'
        version false
        table 'tblAccessRight'
    }

    static constraints = {
        code maxSize: 1
        name nullable: true, maxSize: 64
    }
}

class TblFiscalYear {
    String fiscalYear
    String title
    Boolean active
    Character defaultFy

    static hasMany = [tblAccessRights: TblAccessRight,
                      tblAppropriationGroups: TblAppropriationGroup,
                      tblBudgetProjectNames: TblBudgetProjectName,
                      tblC3ipocs: TblC3ipoc,
                      tblCises: TblCis,
                      tblCommentses: TblComments,
                      tblContractors: TblContractor,
                      tblCotrs: TblCotr,
                      tblDasds: TblDasd,
                      tblDirectors: TblDirector,
                      tblKeys: TblKey,
                      tblMiprpocs: TblMiprpoc,
                      tblObjectiveses: TblObjectives,
                      tblOp32s: TblOp32,
                      tblOrcs: TblOrc,
                      tblPeprojects: TblPeproject,
                      tblProgramElements: TblProgramElement,
                      tblPrograms: TblProgram,
                      tblResourceTypes: TblResourceType,
                      tblResources: TblResource,
                      tblRoles: TblRole,
                      tblTrackChangeses: TblTrackChanges,
                      tblTransactionses: TblTransactions]

    static mapping = {
        id name: "fiscalYear", generator: "assigned" ,type:'string', column:'FiscalYear'
        version false

        table 'tblFiscalYear'
    }

    static constraints = {
        fiscalYear maxSize: 4
        title nullable: true, maxSize: 48
        defaultFy nullable: true, maxSize: 1
    }
}

Upvotes: 0

Views: 621

Answers (1)

dmahapatro
dmahapatro

Reputation: 50245

You have to modify the mappings in TblAccessRight to specify which column (tbl_fiscal_year_id in this case) tblFiscalYear is referring to:

static mapping = {
    table 'tblAccessRight'
    id column: "RightID", generator: "assigned",name:'rightID'
    tblFiscalYear column: 'tbl_fiscal_year_id'
    version false
}

Upvotes: 1

Related Questions