这是我的域类
class TimesheetSubmission {
Date submissionDate=new Date()
String foreman
String shift
String jobId
Date date
byte[] xmlSubmission
String xmlResponse
static constraints = {
submissionDate nullable: false
foreman nullable: false
shift nullable: false
jobId nullable: false
date nullable: false
xmlSubmission nullable: true
xmlResponse nullable: false
}
static mapping = {
xmlSubmission (type: "blob")
}
}
以下是我在数据库中保存数据的代码。
TimesheetSubmission timesheetSubmission=new TimesheetSubmission()
timesheetSubmission.foreman=Party.findById(foremanId)
timesheetSubmission.shift=shift
timesheetSubmission.jobId=jobId
timesheetSubmission.date=Date.parse("yyyy-MM-dd", date)
timesheetSubmission.xmlSubmission=sTimesheet.getBytes();
timesheetSubmission.xmlResponse="response"
timesheetSubmission.save(flush: true,failOnError: true)
我在域名保存时遇到以下错误。
[B cannot be cast to java.sql.Blob
答案 0 :(得分:4)
static mapping = {
xmlSubmission sqlType: 'blob'
}