Grails 2.4.2 Domain will not save more than 8 fields

陌路散爱 提交于 2019-12-24 14:59:04

问题


I am receiving an arrayIndexOutOfBounds exception when I try ta save a new record in my Grails app.

I have narrowed the problem down to only being able to save 8 fields.

Here is my domain class:

package nhvr

class NhvrJourny {

static constraints = {
    nhvrNo nullable:true
    journeyId  nullable:true
    width nullable:true
    vLength nullable:true
    height nullable:true
    rearOverhang nullable:true
        }


    Long nhvrNo
    String journeyId
    String title
    BigDecimal width
    BigDecimal vLength
    BigDecimal height
    BigDecimal rearOverhang

    String toString(){
        return "$nhvrNo $title"
    }
}

Im saving the data via a service. The method looks like this:

    def saveJourny(Map nhvrJourneyPars) {

    if (nhvrJourneyPars?.dateArchived)
        da = df.parse(nhvrJourneyPars.dateArchived)

    Map journeyPars = [
            journeyId     : nhvrJourneyPars.journeyId,
            title         : nhvrJourneyPars.title,
            nhvrNo        : nhvrJourneyPars.nhvrNo,
            width         : nhvrJourneyPars.width,
            vLength       : nhvrJourneyPars.vLength,
            height        : nhvrJourneyPars.height,
            rearOverhang  : nhvrJourneyPars.rearOverhang
    ]
    NhvrJourny nhvrJournyInstance = new NhvrJourny(journeyPars)

    println "journeyPars:"
    journeyPars.each{
        println "${it.key}: ${it.value}"
    }

    if (nhvrJournyInstance == null) {
        println "nhvrJournyInstance is null"
        notFound()
        return
    }

    if (!nhvrJournyInstance.validate()) {
        if (nhvrJournyInstance.hasErrors()) {
            println "Errors: ${nhvrJournyInstance.errors.allErrors}"
            respond nhvrJournyInstance.errors, view: 'create'
            return
        }
    }
    else{
        println "No errors in nhvrJourneysInstance."
    }

    println "nhvrJournyInstance.properties"
    nhvrJournyInstance.properties.each{
        println "   ${it.key}: ${it.value}"
    }
    nhvrJournyInstance.save(flush:true)
    return nhvrJournyInstance
}

I can see the data that gets passed in and it looks OK:

nhvrJournyInstance: {"journeyId":"j1","title":"test","nhvrNo":"2","width":3,"height":3,"vLength":21,"rearOverhang":1}

This is currently returning an ArrayIndexOutOfBounds exception when I call nhvrJournyInstance.save(flush:true)

If I remove one of the fields from the Domain class then the data gets saved. Note: while there are only seven fields shown the ID and version are being added automatically.

I have been testing using run-app from intellij 13.1.4 on windows 7 My Grails version is 2.4.2 and Java version is 1.7.0_60 The database is Oracle 11g using ojdbc6.jar

Can anyone shed some light on this? it is driving me nuts.

EDIT - Here is the stacktrace:

14. Stacktrace follows:
Message: 14
    Line | Method
->>  950 | computeBasicInfo          in oracle.jdbc.driver.OracleSql
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    623 | getSqlKind                in     ''
|   1212 | <init> . . . . . . . . .  in oracle.jdbc.driver.OraclePreparedStatement
|     28 | <init>                    in oracle.jdbc.driver.T4CPreparedStatement
|     68 | allocatePreparedStatement in oracle.jdbc.driver.T4CDriverExtension
|   3140 | prepareStatement          in oracle.jdbc.driver.PhysicalConnection
|   3042 | prepareStatement . . . .  in     ''
|   6022 | prepareStatement          in     ''
|    699 | $tt__saveJourney . . . .  in nhvr.NhvrService
|     58 | $tt__saveJourney          in nhvr.NhvrJourneyController
|    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
^    745 | run . . . . . . . . . . . in java.lang.Thread
enter code here

回答1:


It is a problem with the version of the ojdbc6.jar file that I was using to connect to the DB.

I have downloaded another version of this file, which is 500kb larger, and it is now working.

thanks Jeff for your input.



来源:https://stackoverflow.com/questions/25967846/grails-2-4-2-domain-will-not-save-more-than-8-fields

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!