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
|
|