-->
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.  [ 4 posts ] 
Author Message
 Post subject: save file(>50MB) file using byte[] causes out of memory e
PostPosted: Fri Oct 08, 2004 1:42 pm 
Beginner
Beginner

Joined: Thu Jul 22, 2004 8:09 am
Posts: 20
would like to know if there is any solution to save large file with mapping byte[] to blob.
appreciate any help.

Hibernate version:
2.1.6

Mapping documents:
<class
name="com.xxx.bean.Email"
table="EMAILS"
dynamic-update="true"
dynamic-insert="true"
>
<id
name="emailId"
type="long"
column="EMAIL_ID"
length="22"
>
<generator class="native"/>
</id>
<property
name="emailattachment"
column="EMAILATTACHMENT"
type="com.xxx.BinaryBlobType"
/>

Code between sessionFactory.openSession() and session.close():
File attachment = new File("C:/temp/full_cream.gif");
if (!attachment.exists()) {
assertTrue(true);
return;
}

email.setEmailattachmentfilename(attachment.getName());

InputStream is = new FileInputStream(attachment);
byte[] data = new byte[is.available()];
is.read(data);
is.close();

email.setEmailattachment(data);

Full stack trace of any exception that occurs:

Name and version of the database you are using:
Oracle 9

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 11, 2004 1:35 pm 
Regular
Regular

Joined: Tue Sep 28, 2004 6:34 pm
Posts: 50
did you try:
http://hibernate.bluemars.net/56.html
?

just change CLOB to BLOB (also change some method names).
It works for me, but I haven't tried it with 50 megs (so far).
I just guess that you are refering to out of memory error related to column LONG not jvm out of memory - if it is jvm are you sure it is related to persistence layer?

Lukasz


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 12, 2004 10:11 am 
Beginner
Beginner

Joined: Thu Jul 22, 2004 8:09 am
Posts: 20
1. I have mapped a Blob to byte[] and Clob to String using UserType.
2. I am trying to read a huge file as a byte[] and receive out of memory exception.

Can I change any settings so that dont get this exception?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 12, 2004 12:06 pm 
Regular
Regular

Joined: Tue Sep 28, 2004 6:34 pm
Posts: 50
It is more likely that this is the jvm issue - not the hibernate one.

Comment out the part where you would normaly call persistence layer and try to upload file - I guess it will throw the same exception.

Anyway you should increase the heap stack for java i.e.:
java -Xmx256M -jar yourapp.jar

I do not know how do you launch your app - if you use ant, tomcat whatever try to find the way to pass this parameter.


Lukasz


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.