File too big
cash1981 May 12, 2009 1:17 PMI have an entity called File which until recently I changed from 16MB byte to 100MB max. However it seems like it still thinks its 16MB which is max for the file.
My entity bean:
package no.kommuneforlaget.saksapp.model; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Lob; import javax.persistence.PrePersist; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; import no.kommuneforlaget.saksapp.process.FileReference; import org.hibernate.validator.NotNull; @Entity public class File { @Id @GeneratedValue private Long id; @NotNull @Column(nullable=false,length=256) private String name; @NotNull @Column(nullable=false,length=256) private String processKey; //BLOB = L + 2 bytes (max size is 2^16 - 1 or 65,535 bytes, 65KB) //MEDIUMBLOB = L + 3 bytes (max size is 2^24 - 1 or 16,777,215 bytes, 16MB) //LONGBLOB = L + 4 bytes (max size is 2^32 - 1 or 4,294,967,295 bytes, 4GB) //@Basic(LAZY) not needed since that is the default @Lob //Set to MAX 100MB MEDIUMBLOB in MySQL @Column(length=1024721500, nullable=false) private byte[] data; @Temporal(TemporalType.TIMESTAMP) private Date date; //@Temporal(TemporalType.TIMESTAMP) private Date emailedOn; @PrePersist //@PreUpdate - otherwise the create date will always be the same as the emailed date public void setDate() { date = new Date(); } public void setEmailedOn(Date date) { emailedOn = date; } /** * Set the emailedOn property to now */ public void setEmailedOnNow() { emailedOn = new Date(); } @Transient public FileReference getReference() { if (date==null) { date = new Date(); } return new FileReference(name,id,date,emailedOn); } @Transient public InputStream getInputStream() { return new ByteArrayInputStream(data); } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getProcessKey() { return processKey; } public void setProcessKey(String processKey) { this.processKey = processKey; } public byte[] getData() { return data; } public void setData(byte[] data) { this.data = data; } public Date getDate() { return date; } public void setDate(Date date) { this.date = date; } public Date getEmailedOn() { return emailedOn; } @Transient public String cacheKey() { return "File:"+String.valueOf(id); } }
My show create table File
in the database:
File | CREATE TABLE
File
(
id
bigint(20) NOT NULL auto_increment,
name
varchar(256) NOT NULL,
processKey
varchar(256) NOT NULL,
data
longblob NOT NULL,
date
datetime default NULL,
emailedOn
datetime default NULL, PRIMARY KEY (
id
) ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8
As you can see data has been changed from the previous mediumblob to longblob, however when I try to upload a file bigger than 16MB I get this error:
Caused by: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (21985801 > 16777216). You can change this value on the server by setting the max_allowed_packet' variable.
Caused by: org.hibernate.exception.GenericJDBCException: could not insert: [no.kommuneforlaget.saksapp.model.File] at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103) at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
Now have I forgotten somewhere to update this? I have a create-drop on the database, so that shouldn't be a problem.