I am having an issue with a simple update of a Grails Domain class and I really need a sanity check. 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
Which I assume refers to the Container id in the constructor? 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 =? and version =? for update
One thought, does this have to do with any of the constraints "hasOne"
I am using a MySQL database if that helps. 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 )
This issue mentions a similar error which occurs when using the unique: true
constraint on a one-to-one association. Try removing the unique constraint from containerSolvent
and containerContent
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.