简体   繁体   中英

Grails cannot save object

Im getting a rather strange error trying to save objects to my database. The code has worked perfeclty when trying to save the base class objects but now I am trying to save a domain class that inherits from the base domain class.

Here is the parent class:

package com.twc.fatcaone

class Record {

long batchID

}

and the child class that I am trying to save:

package com.twc.fatcaone

class AccountRecord extends Record {

    long uniqueId
    String accountId
    String type
    String insurance
    String currencyType
    float amount
    String upSerDel
    String generalComments

    static mapping = {
        collection "accountRecords"
        database "twcdb"
}
}

The code in my service that's trying to do the save:

accountRecordList.each { 

                def accountRecord = new AccountRecord(batchID: params.selectedBatch.id,
                                                        uniqueId: it.uniqueId,
                                                        accountId: it.accountId,
                                                        type: it.type,
                                                        insurance: it.insurance,
                                                        currencyType: it.currencyType,
                                                        amount: it.amount,
                                                        upSerDel: it.upSerDel,
                                                        generalComments: it.generalComments)

                       if (!AccountRecord.save(flush: true, failOnError: true)) {
                           println "ERROR: Record could not be saved!"
                           def errorValue = AccountRecord.errors
                           println errorValue
                       }

and the error I get when trying to do the save:

/FatcaOne_0/customer/upload - parameters: dataTypegrp: 1 fileTypegrp: 1 No signature of method: com.twc.fatcaone.AccountRecord.save() is applicable for argument types: (java.util.LinkedHashMap) values: [[flush:true, failOnError:true]] Possible solutions: save(), save(), save(boolean), save(java.util.Map), save(boolean), save(java.util.Map). Stacktrace follows: Message: No signature of method: com.twc.fatcaone.AccountRecord.save() is applicable for argument types: (java.util.LinkedHashMap) values: [[flush:true, failOnError:true]] Possible solutions: save(), save(), save(boolean), save(java.util.Map), save(boolean), save(java.util.Map) Line | Method ->> 91 | methodMissing in org.grails.datastore.gorm.GormStaticApi /FatcaOne_0/customer/upload - parameters: dataTypegrp: 1 fileTypegrp: 1 No signature of method: com.twc.fatcaone.AccountRecord.save() is applicable for argument types: (java.util.LinkedHashMap) values: [[flush:true, failOnError:true]] Possible solutions: save(), save(), save(boolean), save(java.util.Map), save(boolean), save(java.util.Map). Stacktrace follows: Message: No signature of method: com.twc.fatcaone.AccountRecord.save() is applicable for argument types: (java.util.LinkedHashMap) values: [[flush:true, failOnError:true]] Possible solutions: save(), save(), save(boolean), save(java.util.Map), save(boolean), save(java.util.Map) Line | Method ->> 91 | methodMissing in org.grails.datastore.gorm.GormStaticApi - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 32 | call in org.grails.datastore.gorm.internal.StaticMethodInvokingClosure | 65 | doCall . . . . . . . . . . in com.twc.fatcaone.FileImportService$_$tt__excelAccountFileUpload_closure4 | 53 | $tt__excelAccountFileUpload in com.twc.fatcaone.FileImportService | 119 | upload . . . . . . . . . . in com.twc.fatcaone.CustomerController | 198 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter | 63 | doFilter . . . . . . . . . in grails.plugin.cache.web.filter.AbstractFilter | 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor | 615 | run . . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker ^ 744 | run in java.lang.Thread /FatcaOne_0/customer/upload - parameters: dataTypegrp: 1 fileTypegrp: 1 No signature of method: com.twc.fatcaone.AccountRecord.save() is applicable for argument types: (java.util.LinkedHashMap) values: [[flush:true, failOnError:true]] Possible solutions: save(), save(), save(boolean), save(java.util.Map), save(boolean), save(java.util.Map). Stacktrace follows: Message: No signature of method: com.twc.fatcaone.AccountRecord.save() is applicable for argument types: (java.util.LinkedHashMap) values: [[flush:true, failOnError:true]] Possible solutions: save(), save(), save(boolean), save(java.util.Map), save(boolean), save(java.util.Map) Line | Method ->> 91 | methodMissing in org.grails.datastore.gorm.GormStaticApi - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 32 | call in org.grails.datastore.gorm.internal.StaticMethodInvokingClosure | 65 | doCall . . . . . . . . . . in com.twc.fatcaone.FileImportService$_$tt__excelAccountFileUpload_closure4 | 53 | $tt__excelAccountFileUpload in com.twc.fatcaone.FileImportService | 119 | upload . . . . . . . . . . in com.twc.fatcaone.CustomerController | 198 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter | 63 | doFilter . . . . . . . . . in grails.plugin.cache.web.filter.AbstractFilter | 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor | 615 | run . . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker ^ 744 | run in java.lang.Thread /FatcaOne_0/customer/upload - parameters: dataTypegrp: 1 fileTypegrp: 1 No signature of method: com.twc.fatcaone.AccountRecord.save() is applicable for argument types: (java.util.LinkedHashMap) values: [[flush:true, failOnError:true]] Possible solutions: save(), save(), save(boolean), save(java.util.Map), save(boolean), save(java.util.Map). Stacktrace follows: Message: No signature of method: com.twc.fatcaone.AccountRecord.save() is applicable for argument types: (java.util.LinkedHashMap) values: [[flush:true, failOnError:true]] Possible solutions: save(), save(), save(boolean), save(java.util.Map), save(boolean), save(java.util.Map) Line | Method ->> 91 | methodMissing in org.grails.datastore.gorm.GormStaticApi - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 32 | call in org.grails.datastore.gorm.internal.StaticMethodInvokingClosure | 65 | doCall . . . . . . . . . . in com.twc.fatcaone.FileImportService$_$tt__excelAccountFileUpload_closure4 | 53 | $tt__excelAccountFileUpload in com.twc.fatcaone.FileImportService | 119 | upload . . . . . . . . . . in com.twc.fatcaone.CustomerController | 198 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter | 63 | doFilter . . . . . . . . . in grails.plugin.cache.web.filter.AbstractFilter | 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor | 615 | run . . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker ^ 744 | run in java.lang.Thread /FatcaOne_0/customer/upload - parameters: dataTypegrp: 1 fileTypegrp: 1 No signature of method: com.twc.fatcaone.AccountRecord.save() is applicable for argument types: (java.util.LinkedHashMap) values: [[flush:true, failOnError:true]] Possible solutions: save(), save(), save(boolean), save(java.util.Map), save(boolean), save(java.util.Map). Stacktrace follows: Message: No signature of method: com.twc.fatcaone.AccountRecord.save() is applicable for argument types: (java.util.LinkedHashMap) values: [[flush:true, failOnError:true]] Possible solutions: save(), save(), save(boolean), save(java.util.Map), save(boolean), save(java.util.Map) Line | Method ->> 91 | methodMissing in org.grails.datastore.gorm.GormStaticApi - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 32 | call in org.grails.datastore.gorm.internal.StaticMethodInvokingClosure | 65 | doCall . . . . . . . . . . in com.twc.fatcaone.FileImportService$_$tt__excelAccountFileUpload_closure4 | 53 | $tt__excelAccountFileUpload in com.twc.fatcaone.FileImportService | 119 | upload . . . . . . . . . . in com.twc.fatcaone.CustomerController | 198 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter | 63 | doFilter . . . . . . . . . in grails.plugin.cache.web.filter.AbstractFilter | 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor | 615 | run . . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker ^ 744 | run in java.lang.Thread - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 32 | call in org.grails.datastore.gorm.internal.StaticMethodInvokingClosure | 65 | doCall . . . . . . . . . . in com.twc.fatcaone.FileImportService$_$tt__excelAccountFileUpload_closure4 | 53 | $tt__excelAccountFileUpload in com.twc.fatcaone.FileImportService | 119 | upload . . . . . . . . . . in com.twc.fatcaone.CustomerController | 198 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter | 63 | doFilter . . . . . . . . . in grails.plugin.cache.web.filter.AbstractFilter | 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor | 615 | run . . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker ^ 744 | run in java.lang.Thread

难道不是在调用save函数之前在AccountRecord一词中使用小写的“ a”吗?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM