pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Radosław Smogura <rsmogura@softperience.eu>
To: pgsql-jdbc@postgresql.org
Subject: Re: Migration to Hibernate 3.5 final
Date: Sat, 10 Apr 2010 14:58:54 +0200
Message-ID: <201004101458.54501.rsmogura@softperience.eu> (raw)

I had similar problems, try use on byte[] field following Hibernate annotation 
@Type(type="org.hibernate.type.PrimitiveByteArrayBlobType")

Dnia sobota 10 kwiecień 2010 o 13:36:42 Craig Ringer napisał(a):
> Rafael Felix wrote:
> > I´ve an application running in hibernate 3.3.2 and the applications
> > works fine, with all blob fields using oid (byte[] in java),
> 
> Do you mean you're using the literal type `oid' in the Pg fields? Or are
> you using the `lo' contrib type?
> 
> By using the `oid' type you're using out-of-line large objects,
> referenced by object id (oid).
> 
> If you use `oid' directly, then when you delete a row from your table
> the corresponding large object will NOT be deleted. The `lo' wrapper
> contrib type provides that. It's not in mainline yet (alas), perhaps
> because it can't guarantee correctness - in particular a TRUNCATE TABLE
> will still leak large objects.
> 
> > Migrating to hibernate 3.5 all blob fields not work anymore, and the
> > server log shows
> >
> > ERROR org.hibernate.util.JDBCExceptionReporter - ERROR: column
> > "preferencia" is of type oid but expression is of type bytea
> 
> OK, so you're now mapping byte[] to the Pg type 'bytea' instead of to pg
> large objects.
> 
> You can change this mapping in your hibernate settings if you want
> things to go back to how they were. See large object mapping in the
> Hibernate documentation.
> 
> > But I'm cann't change the tables struct for use bytea instead oid,
> > because I lost all data.
> 
> Do you mean "because you've lost all your data" or "because by doing so
> you will lose all your data"?
> 
> I presume the latter.
> 
> What I'd do would be:
> 
> a) Change hibernate's mapping for byte[] back to large object instead of
> bytea by overriding it in the Hibernate configuration
> 
> b) Evaluate whether bytea or large object is actually better for you by
> reading the postgresql documentation and thinking a about your needs.
> Consider how often you update the data, how big the maximum size of
> object you need to store is, etc.
> 
> c) Decide whether you should migrate to bytea or stick with large objects.
> 
> d) If you stick to large objects, switch from raw oid types to `lo'
> types, so you get proper large object cleanup on delete/update. Consider
> using vacuumlo .
> 
> --
> Craig Ringer
> 



view thread (6+ messages)  latest in thread

Message-ID: <201004101458.54501.rsmogura@softperience.eu>
Permalink:  ../201004101458.54501.rsmogura@softperience.eu/
Also on:    postgresql.org/message-id/201004101458.54501.rsmogura@softperience.eu

 · 

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: rsmogura@softperience.eu
  Subject: Re: Migration to Hibernate 3.5 final
  In-Reply-To: <201004101458.54501.rsmogura@softperience.eu>
  References: <201004101458.54501.rsmogura@softperience.eu>

* 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