Grails 2.4.2域不会保存超过8个字段 [英] Grails 2.4.2 Domain will not save more than 8 fields

查看:106
本文介绍了Grails 2.4.2域不会保存超过8个字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



我将问题缩小到只能保存8个



以下是我的域类:

  package nhvr 

class NhvrJourny {

静态限制= {
nhvr无空值:true
journeyId可空值:true
宽度可为空: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)

地图journeyPars = [
journeyId:nhvrJourneyPars.journeyId,
标题:nhvrJourneyPars.title,
nhvrNo:nhvrJourneyPars.nhvrNo,
width:nhvrJourneyPars.width,
vLength:nhvrJourneyPars.vLength,
height:nhvrJourneyPars.height,
rearOverhang:nhvrJourneyPars.rearOverhang

NhvrJourny nhvrJournyInstance = new NhvrJourny(journeyPars)

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


if(nhvrJournyInstance == null){
printlnnhvrJournyInstance is null
notFound()
return
}

if(!nhvrJournyInstance.validate()){
if(nhvrJournyInstance.hasErrors()){
println错误:$ {nhvrJournyInstance.errors.allErrors}
响应nhvrJournyInstance.errors,查看:'create'
return
}
}
else {
printlnnhvrJourneysInstance中没有错误。
}

printlnnhvrJournyInstance.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类中删除一个字段,那么数据会被保存。注意:虽然只显示了7个字段,但ID和版本自动添加。



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



任何人都可以点亮一些光在这?这是推动我坚果。

编辑 - 这是堆栈跟踪:

  14。 Stacktrace如下:
消息:14
Line |方法
- >> 950 |在oracle.jdbc.driver.OracleSql中的computeBasicInfo
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - b $ b | 623 | getSqlKind在''
|中1212 | < INIT> 。 。 。 。 。 。 。 。 。在oracle.jdbc.driver.OraclePreparedStatement
|中28 | < INIT>在oracle.jdbc.driver.T4CPreparedStatement
|中68 | allocatePreparedStatement in oracle.jdbc.driver.T4CDriverExtension
| 3140 | oracle.jdbc.driver.PhysicalConnection
|中的prepareStatement 3042 | prepareStatement。 。 。 。在''
|中6022 |在''
|中准备语句699 | $ tt__saveJourney。 。 。 。在nhvr.NhvrService
|中58 | $ tt__saveJourney在nhvr.NhvrJourneyController
| 198 | doFilter。 。 。 。 。 。 。 。在grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
| 1145 | runWorker。 。 。 。 。 。 。 。在java.util.concurrent.ThreadPoolExecutor
|中615 |在java.util.concurrent.ThreadPoolExecutor $ Worker
^ 745 |中运行跑 。 。 。 。 。 。 。 。 。 。 。在java.lang.Thread中
在此处输入代码


解决方案

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



我下载了另一个版本的这个文件,它现在正在工作。



感谢Jeff的宝贵意见。


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

解决方案

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.

这篇关于Grails 2.4.2域不会保存超过8个字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆