These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]

Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: File size is twice the real size at insert request in a blob
PostPosted: Thu Jan 07, 2016 9:18 am 

Joined: Thu Jan 07, 2016 8:56 am
Posts: 1
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.
parameter is set to 16Mb.

When trying to insert a file of 10Mb (serialized size = 13Mb) in this table, we have the following error :
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
to 32Mb but it's an ugly one.

Does anyone have encountered the same problem ?

Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.