gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 03:45:03 25 4
gpt4 key购买 nike

当我尝试在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com