java - Grails 2.4.2 域不会保存超过 8 个字段

标签 java oracle grails intellij-idea grails-domain-class

当我尝试在 Grails 应用程序中保存新记录时,收到 arrayIndexOutOfBounds 异常。

我已将问题范围缩小到只能保存 8 个字段。

这是我的域类:

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"
    }
}

我通过服务保存数据。该方法如下所示:

    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
}

我可以看到传入的数据,看起来不错:

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

当我调用 nhvrJournyInstance.save(flush:true) 时,当前返回 ArrayIndexOutOfBounds 异常

如果我从 Domain 类中删除其中一个字段,则会保存数据。注意:虽然只显示了七个字段,但 ID 和版本会自动添加。

我一直在 Windows 7 上使用 intellij 13.1.4 中的 run-app 进行测试 我的 Grails 版本是 2.4.2,Java 版本是 1.7.0_60 数据库是Oracle 11g,使用ojdbc6.jar

有人能解释一下吗?这让我发疯。

编辑 - 这是堆栈跟踪:

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

最佳答案

这是我用来连接数据库的 ojdbc6.jar 文件版本的问题。

我已经下载了该文件的另一个版本,它大了 500kb,现在可以正常工作了。

感谢杰夫的意见。

关于java - Grails 2.4.2 域不会保存超过 8 个字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25967846/

相关文章:

java - 超过一个按钮会使我的应用程序崩溃

java - JBAS011843 : Failed instantiate InitialContextFactory org. jnp.interfaces.NamingContextFactory 用于 Wildfly 8.0

database - 什么时候使用表集群?

database - 将整体拆分为微服务数据库问题

ajax - 如何在 View 页面上显示服务器端验证错误

svn - Grails 应用程序和版本控制

grails - Grails Controller 在表中插入两行,而我仅调用一次

java - 如何构建 "Thinking in Java"示例文件以在 Eclipse IDE 中运行?

java - 为不同的客户共享网络应用程序

oracle - 如何提高基于 SCN 的查询性能?