-->
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 upload, JPA, BLOBs and InputStream
PostPosted: Thu Aug 21, 2008 5:52 am 
Newbie

Joined: Tue Apr 08, 2008 5:19 am
Posts: 1
Location: UK
Hi!

I am working with a project which has Hibernate 3.2.6.ga under JPA. At the moment we are using H2 as a development database but later on we will move to Oracle.

One of the features of the application is file upload and in order to keep memory usage low we try to avoid storing files as byte array. I took a look inside org.hibernate.lob.BlobImpl.java and it uses InputStream as well for data.

In our application we have following for the uploads:
Code:
// dataStream is the uploaded file as an InputStream
Blob dataBlob = new BlobImpl(dataStream, dataSize);

// Domain object FileData has a field of java.sql.Blob for the dataBlob
FileData fileData = new FileData(dataBlob);


The fileData object is then persisted using EntityManager.

In the Hibernate mapping I used type="blob" for this property.

My question is that is this approach good enough or is there better way like native SQL queries? File sizes are under 100MB.

Thank you!


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.