pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stefan Keller <sfkeller@gmail.com>
To: pgsql-general List <pgsql-general@postgresql.org>
Subject: Binary Large Objects (LOB/BLOB) in Hibernate and JDBC: Unresolved issues
Date: Fri, 6 Jan 2012 19:04:06 +0100
Message-ID: <CAFcOn2-bkFBdBUTa-dRudE0gC6bJbPNVDEV-+LOs40PaDHUhUQ@mail.gmail.com> (raw)

Hi,

I run into a nasty behavior of current PostgreSQL JDBC.

I maintain images (from Webcams). In the Java and Hibernate (JPA) code
I specified a @Lob annotation on class MyData and a attribte/data type
"byte[] mydata;". Hibernate then generates two tables in PostgreSQL,
one called MyData with a column mydata of type oid and an internal one
called pg_largobjects (which contain foreign keys to the oid). That's
also explained in the JDBC docs [1], saying "PostgreSQL provides two
distinct ways to store binary data. Binary data can be stored in a
table using the data type bytea or by using the Large Object feature
which stores the binary data in a separate table in a special format
and refers to that table by storing a value of type oid in your
table."

Now, when replacing the images (few hundred) with new ones using Java,
pg_largeobjects grew constantly until the file system run out of
space. So old image data did'nt get released! This is to me a bug
because the user/programmer must (and should) assume that there is a
strict 1:1 relationship between generated table MyData and its LOB
column data (stored in pg_largeobjects).
=> I finally found the supplied module 'lo' [2] which releases
detached records. Is this the recommended way to resolve this problem?

Searching for explanations I found a ticket HHH2244 [3] which was
closed by the Hibernate team without action referring to the JDBC
Spec. which says: "An SQL BLOB is a built-in type that stores a Binary
Large Object as a column value in a row of a database table".
=> In other words: The PostgreSQL JDBC team should take action on this
but didn't until now, right?

There is another issue about "PostgreSQL and BLOBs" [4]. First it
cites PostgreSQL JDBC docs [1]. The thread [4] ends somehow too in a
'deadlock' concluding  "...the PostgreSQLDialect (as of 3.5.5) needs
to change not to use MaterializedBlobType until the Postgres (JDBC)
team changes their driver (which does not seem to have happened in the
last 6 years)."
=> Any solutions or comments form insiders on this?

Yours, Stefan

[1] http://jdbc.postgresql.org/documentation/head/binary-data.html
[2] http://www.postgresql.org/docs/current/interactive/lo.html
[3] https://hibernate.onjira.com/browse/HHH-2244
[4] http://relation.to/Bloggers/PostgreSQLAndBLOBs



view thread (25+ messages)  latest in thread

Message-ID: <CAFcOn2-bkFBdBUTa-dRudE0gC6bJbPNVDEV-+LOs40PaDHUhUQ@mail.gmail.com>
Permalink:  ../CAFcOn2-bkFBdBUTa-dRudE0gC6bJbPNVDEV-+LOs40PaDHUhUQ@mail.gmail.com/
Also on:    postgresql.org/message-id/CAFcOn2-bkFBdBUTa-dRudE0gC6bJbPNVDEV-+LOs40PaDHUhUQ@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: sfkeller@gmail.com, pgsql-general@postgresql.org
  Subject: Re: Binary Large Objects (LOB/BLOB) in Hibernate and JDBC: Unresolved issues
  In-Reply-To: <CAFcOn2-bkFBdBUTa-dRudE0gC6bJbPNVDEV-+LOs40PaDHUhUQ@mail.gmail.com>
  References: <CAFcOn2-bkFBdBUTa-dRudE0gC6bJbPNVDEV-+LOs40PaDHUhUQ@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox