-->
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: Populating blob columns with large amounts of data?
PostPosted: Tue Mar 23, 2004 9:20 pm 
Regular
Regular

Joined: Wed Dec 17, 2003 1:58 pm
Posts: 102
Hi I've got a file upload situation.. I'm using MySQL on a linux machine, here is the mapping to the class I'm referencing:

<hibernate-mapping>
<class name="File" table="file">
<id name="id" type="long" unsaved-value="null">
<generator class="identity"/>
</id>
<property name="date"/>
<property name="description">
<column name="description" sql-type="mediumtext"/>
</property>
<property name="fileData">
<column name="fileData" sql-type="longblob"/>
</property>
<property name="fileName"/>
<set name="fileQueryValues" cascade="all-delete-orphan" lazy="true" order-by="name asc">
<key column="file_id"/>
<one-to-many class="cmcflex.salesweb.model.file.FileQueryValue"/>
</set>
<property name="title"/>
</class>

</hibernate-mapping>

the fileData object is of type java.sql.Blob. Whenever I try to persist something very big to the database (5meg breaks it.. not sure what the upper limit is) I get this exception:

net.sf.hibernate.JDBCException: could not insert: [File]
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:585)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:479)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:877)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:818)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:738)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:718)

Caused by: java.sql.SQLException: Communication link failure: com.mysql.jdbc.PacketTooBigException
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:885)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:956)
at com.mysql.jdbc.Connection.execSQL(Connection.java:1874)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1700)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1569)

Is there someway to break it up to insert piece by piece? Or what needs to be done? I know that field in the database can hold up to 4 gig so I'm puzzled at how to populate it =)

Thanks in advance,
David


Top
 Profile  
 
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.