Hi,
I would like to know what is the best approach to store a big binary file, say 20-30 MB in Oracle 10g database using hibernate.
My current approach is:
1) In the pojo file I will write:
Code:
private Blob content;
And…
Code:
public void setContent(byte[] buffer)
{
if( buffer != null && buffer.length > 0 ) {
content = Hibernate.createBlob(buffer);
}
}
2) In the hbm.xml file I will write:
Code:
<property
length="31457280"
name="content"
type="blob"
update="true"
insert="true"
access="property"
column="CONTENT"
not-null="false"
lazy="true"
/>
3) Creating the table in (oracle) database is done by the following sql fragment:
Code:
create table BINARY_FILE_TBL (ID number(10,0) not null, CONTENT blob,…
Although the above code is working, I do not know if it optimized and maybe there is a better way to handle insertion and retrieving
LOTS and
LARGE binary files.
BTW: I also used a tablespace
Code:
(create tablespace binTB
logging
datafile 'binTB.dbf'
size 128m
autoextend on
next 32m maxsize unlimited
extent management local; )
in oracle database specific for that binary table.
I am using Hibernate 3.1 rc2, Oracle 10.2g (with thin driver)
Please, any comment will be appreciated.
THANKS.
simon.