Hibernate version: 2
Mapping documents:
<hibernate-mapping package="xxx.File">
<class name="File"
table="file">
<id name="fileId"
type="java.lang.Long"
column="file_id">
<generator class="sequence">
<param name="sequence">sec_file</param>
</generator>
</id>
<property
name="imagen"
column="imagen"
type="binary"
not-null="true"
/>
</hibernate-mapping>
Name and version of the database you are using: PostgreSQL 7.4
Java version: Java 1.4
Container: Tomcat5 using connection pooling
Problem Description:
I have a table which stores files. Using PostgreSQL I decided to use a bytea column to store the data. This is the best type for my system.
To map the colum I used "type=binary", but There is a problem when the file is big (eg. 50MB), because In the Class I have to converted it to a byte[] and this put all the file in memory causing an "out of memory" error in tomcat5. I can reserve more memory for tomcat5, but it isn't the best solution, i think, because it could be serveral clients saving and retrieving files.
I ask you for help or clues to find a solution in wich I can save the file without put it all in memory, with a BufferedStream or something like that.
Thank you for your patience and help.
|