![](/img/trans.png)
[英]Generating a new Domain class with same fields as original Domain class in grails
[英]Grails 2.4.2 Domain will not save more than 8 fields
嘗試在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
誰能對此有所啟發? 它讓我發瘋。
編輯-這是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
我用來連接數據庫的ojdbc6.jar文件的版本存在問題。
我已經下載了該文件的另一個版本,該版本的大小增加了500kb,現在可以正常使用了。
感謝Jeff的意見。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.