We user MySQL + Hibernate 4.3.8 + JPA (+ Spring) for our project.
We have created an entity which is mapped to a table with a blob column, declared as a JPA @Lob.
MySQL
Code:
max_allowed_packet
parameter is set to 16Mb.
When trying to insert a file of 10Mb (serialized size = 13Mb) in this table, we have the following error :
Code:
Caused by: org.hibernate.exception.GenericJDBCException: could not execute statement
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:112)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:211)
at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:96)
...
Caused by: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (
26667037 > 16777216). You can change this value on the server by setting the max_allowed_packet' variable.
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3540)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2417)
It seems that Hibernate generates a request with an object that has twice the size of the original object.
The only solution we have found is to set MySQL
Code:
max_allowed_packet
to 32Mb but it's an ugly one.
Does anyone have encountered the same problem ?