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!