You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Oleg Zenzin <ze...@intalio.com> on 2009/02/28 20:20:40 UTC

exact point when DB updates

Hi

I'm working with Ingres DB and have experienced some problems with during
update of an entity with BLOB. Our platform tested and works with several
DBMS, such as MySQL, Derby, Oracle, Postgres, Sybase. We use both Hibernate
and OpenJPA (versions 1.1.0 and 1.3.0).

The problem with BLOBs on Ingres comes out when application tries to insert
or update new entity with one BLOB field. At first we thought the problem is
in Ingres JDBC because it does not support scrollable ResultSet when result
contains a BLOB field. But looks like OpenJPA does not need scrollable
cursor for updates. I have compared runtime with MySQL and I as far as I
could see forward, read-only ResultSets are used there.

My question would be: where in OpenJPA code the real update (insert) to DB
is called? How it designed to work with BLOBs (through OutputStream,
java.sql.Blob)?

Thank you,
-Oleg Zenzin

Re: exact point when DB updates

Posted by MiƂosz Tylenda <mt...@o2.pl>.
Hi Oleg,

OpenJPA does not currently ship with a dictionary for Ingres. Have you written your own?

I am currently working on an update for Firebird dictionary and had a glance on how BLOB stuff works. It looks like various code paths are taken depending on how you annotate your BLOB.

If you use BLOB streaming (for examples, see test classes and entities in org.apache.openjpa.jdbc.meta.strats package, test directory) the methods like insertBlobForStreamingLoad and updateBlob from DBDictionary are called.

If you use BLOBs in the JPA-compliant way, e.g.:

    @Lob
    public byte[] getBlobin() {
        return blobin;
    }
    public void setBlobin(byte[] blob) {
        this.blobin = blob;
    }

then the following DBDictionary properties affect how the BLOB is handled:

    public boolean useGetBytesForBlobs = false;
    public boolean useSetBytesForBlobs = false;
    public boolean useGetObjectForBlobs = false;

A good point to start is to set

        useGetBytesForBlobs = true;
        useSetBytesForBlobs = true;

in your database dictionary and see what happens.

A similar behaviour applies to CLOBs. You can look into the source, mainly DBDictionary and LobFieldStrategy, to get the very details, if you haven't looked yet.

Hope I haven't missed anything and this helps,
Milosz


> Hi
> 
> I'm working with Ingres DB and have experienced some problems with during
> update of an entity with BLOB. Our platform tested and works with several
> DBMS, such as MySQL, Derby, Oracle, Postgres, Sybase. We use both Hibernate
> and OpenJPA (versions 1.1.0 and 1.3.0).
> 
> The problem with BLOBs on Ingres comes out when application tries to insert
> or update new entity with one BLOB field. At first we thought the problem is
> in Ingres JDBC because it does not support scrollable ResultSet when result
> contains a BLOB field. But looks like OpenJPA does not need scrollable
> cursor for updates. I have compared runtime with MySQL and I as far as I
> could see forward, read-only ResultSets are used there.
> 
> My question would be: where in OpenJPA code the real update (insert) to DB
> is called? How it designed to work with BLOBs (through OutputStream,
> java.sql.Blob)?
> 
> Thank you,
> -Oleg Zenzin
>