Subject Re: [Firebird-Java] Which Java datatype is best for a blob?
Author Roman Rokytskyy
> I would like to ask for suggestions on which Java datatype I should use
> in POJOs for columns which are blobs (either containing text or binary
> data)
>
> What is better? java.sql.Blob, or byte[] ? Or something else?

Depends on the size of the data in the Blob.

- java.sql.Blob is bad choice anyway, since you will have problems
accessing its content not in the same connection/transaction.

- byte[] does the job quite well, but for small blobs. You don't
really want to transfer megabytes from/database each time you access the
blob.

There was nice article about blobs in Hibernate, you can try to find it
on their site.

I would personally write some methods in DAO to fetch the data for the
specified ID when needed.

Also I would use java.io.InputStream to get the data - it has the most
lightweight impact and the highest performance when accessed properly
(basically input stream reads data directly from the stream, all other
types have also type conversion code).

Roman