-->
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.  [ 2 posts ] 
Author Message
 Post subject: Out of memory with Blob
PostPosted: Sun Sep 11, 2005 3:20 pm 
Newbie

Joined: Sun Sep 11, 2005 3:09 pm
Posts: 1
Hi,

I'm trying to use Hibernate to store Blob (87MB) in MySQL and I get an Out Of Memory error. It works fine if if write custom JDBC code. It seems that Hibernate loads all binary data into memory instead of saving using a small buffer to save data. Is it a known problem or do I make a mistake in my hibernate config (see below).

Hibernate version: 3.0.5
<property name="hibernate.jdbc.batch_size">0</property>
<property name="hibernate.jdbc.use_streams_for_binary">true</property>
<property name="hibernate.cache.use_query_cache">false</property>

Mapping documents:
<hibernate-mapping>

<class name="sample.Record" table="UPLOADS">
<id name="id" column="UPLOADID" type="long" unsaved-value="0">
<generator class="increment" />
</id>
<property name="filename" type="string" column="FILENAME"/>
<property name="filedata" type="blob" column="BINARYFILE"/>
</class>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
Transaction tx = session.beginTransaction();
Record record = new Record();
record.setFilename(file.getFileName());
record.setFiledata(Hibernate.createBlob(file.getInpuStream()));
session.save(record);
tx.commit();

Full stack trace of any exception that occurs:
OutOfMemory

Name and version of the database you are using:
MySQL 4.0.18 with set-variable = max_allowed_packet=100M
And ConnectorJ 3.1 JDBC Driver.

The generated SQL (show_sql=true):
Hibernate: insert into UPLOADS (FILENAME, BINARYFILE, UPLOADID) values (?, ?, ?)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 13, 2005 5:07 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Write a UserType that mimic your JDBC code.

_________________
Emmanuel


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

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.