Is there a way to read and write from a blob in chunks using Hibernate.
Right now I am getting OutOfmemoryException because the whole blob data is loaded in memory into a byte[].
To be more specific, let's say I want to save a large file into a database table called File.
public class File {
private byte[] data;
}
I open the file in a FileInputStream and then what?
How do I tell Hibernate that I need to stream the content and will not give the whole byte[] array at once?
Should I use Blob instead of byte[]? Anyway how can I stream the content?
Regarding reading, is there a way I can tell hibernate that (besides the lazy loading it does) I need the blob to be loaded in chunks, so when I retrieve my File it should not give me OutOfMemoryException.
I am using:
- Oracle 11.2.0.3.0
- Hibernate 4.2.3 Final
- Oracle Driver 11.2