[英]Issue Updating Grails Domain Class
I am having an issue with a simple update of a Grails Domain class and I really need a sanity check. 我有一个简单更新Grails Domain类的问题,我真的需要一个健全性检查。 My domain class is 我的域名是
class Container implements Serializable{
String barcode
Float tare
static hasOne = [containerContent:ContainerContent, containerSolvent:ContainerSolvent]
static constraints = {
barcode blank: false, nullable: false, unique: true, size: 0..100
containerSolvent blank: true, nullable: true, unique: true
containerContent blank: true, nullable: true, unique: true
tare blank: true, nullable: true
}}
When I try to update the Containers property "tare" in the following manner I am getting an error (below) 当我尝试以下列方式更新容器属性“皮重”时,我收到错误(如下)
myFoundContainer = Container.findByBarcode(contents.get("barcode"))
def myContainer = Container.get(myFoundContainer.id )
def myTare = contents.get("tare")
try{
myContainer.lock()
myContainer.tare = myTare
myContainer.save(flush:true)
}
catch (org.springframework.dao.OptimisticLockingFailureException e) {
println(e)
}
I then get the error: 然后我得到错误:
No value specified for parameter 1 java.sql.SQLException 没有为参数1 java.sql.SQLException 指定值
Which I assume refers to the Container id in the constructor? 我假设它是指构造函数中的Container id? But I did not think this would matter during an update. 但我认为在更新期间这不重要。
In the console I also see the following message: 在控制台中我也看到以下消息:
Hibernate: select id from container where id =? Hibernate:从容器中选择id,其中id =? and version =? 和版本=? for update 更新
One thought, does this have to do with any of the constraints "hasOne" 一想法,这是否与任何限制“hasOne”有关
I am using a MySQL database if that helps. 如果有帮助,我正在使用MySQL数据库。 Thank you for any assistance. 谢谢你的帮助。
No value specified for parameter 1. Stacktrace follows:
Message: No value specified for parameter 1
Line | Method
->> 1074 | createSQLException in com.mysql.jdbc.SQLError
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 988 | createSQLException in ''
| 974 | createSQLException . in ''
| 919 | createSQLException in ''
| 2611 | checkAllParametersSet in com.mysql.jdbc.PreparedStatement
| 2586 | fillSendPacket in ''
| 2510 | fillSendPacket . . . in ''
| 2259 | executeQuery in ''
| 96 | executeQuery . . . . in org.apache.commons.dbcp.DelegatingPreparedStatement
| 358 | uploadMethod in com.sagerx.UpdateContainerStatusUponReceiptService$$EOHFXFJX
| 24 | uploadFile . . . . . in com.sagerx.UpdateContainerStatusController
| 195 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter . . . . . . in grails.plugin.cache.web.filter.AbstractFilter
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run in java.lang.Thread
This might be related to this Grails JIRA Issue (also mentioned in this question ) 这可能与此Grails JIRA问题有关 (在本问题中也有提及)
This issue mentions a similar error which occurs when using the unique: true
constraint on a one-to-one association. 此问题提到了在一对一关联上使用unique: true
约束时发生的类似错误。 Try removing the unique constraint from containerSolvent
and containerContent
尝试从containerSolvent
和containerContent
删除唯一约束
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.