我正在为grails应用程序使用image-gallery插件。它可以保存小于2kb的小图像。但是当我尝试保存大图像时,它不会保存。甚至更大的4kb图像也无法保存。并显示以下异常:
Class
java.sql.BatchUpdateException
Message
ORA-24816: Expanded non LONG bind data supplied after actual LONG or LOB column
以下是我的域名。我从图片库插件修改了:
package org.grails.plugins.imagegallery
import javax.swing.ImageIcon
import org.codehaus.groovy.grails.commons.ConfigurationHolder as CH
/**
* Image holds the image bytes, its thumbnail and other properties related to an Image.
* Image data field is required. Height, Width and thumbnail are created updating or creating an image.
*/
class Image {
byte[] thumbnail
String caption
String description
byte[] data
Integer width
Integer height
static mapping = {
version(false)
caption column: 'caption'
description column: 'description'
width column: 'width'
height column: 'height'
data column:'data',type:org.hibernate.type.MaterializedBlobType
thumbnail column: 'thumbnail'
}
static constraints = {
description(nullable: true)
thumbnail(nullable: true)
caption(nullable: true)
data(maxSize:1073741824)
width(nullable: true)
height(nullable: true)
}
def beforeInsert = {
java.awt.Image img = new ImageIcon(this?.data).getImage();
this?.height = img.getHeight(null);
this?.width = img.getWidth(null);
loadThumbnail()
}
def beforeUpdate = {
loadThumbnail()
}
/**
* Creates the thumbnail. Takes maxWidth and maxHeight from config.groovy if provided
* otherwise cosiders the default max width & height as 170 & 120 respectively.
*/
public void loadThumbnail() {
if (this.data) {
def imageUtil = new ImageUtil()
imageUtil.load(data)
float maxWidth = CH?.config?.grails?.imageGallery?.thumbnail?.maxWidth?:170
float maxHeight = CH?.config?.grails?.imageGallery?.thumbnail?.maxWidth?:120
imageUtil.thumbnailSpecial(maxWidth, maxHeight, 1,1)
this.thumbnail = imageUtil.getBytes("JPEG")
}
}
}
任何帮助都将不胜感激。
感谢。