0 Replies Latest reply on Dec 23, 2008 4:44 AM by Jose Antonio

    BLOB handling with Postgresql

    Jose Antonio Newbie

      Hello, I'm developing an application using JBoss 4.2.3. I have to store some XML documents in a database and I have to read, and update them. These documents will be encrypted eventually so I have defined an entity like this:

      public abstract class Document implements Serializable {

      protected long id;

      protected byte[] content;

      protected String username;

      getters and setters

      I'm using PostgreSQL 8.3 as my backend.

      Hibernate generates a table for this entity with a field of type 'oid' for the row content and it stores the real content in the common table pg_largeobjects. The problem is that, everytime that I update the field content, it generates a new entry in pg_largeobjects and updates the oid field but it does not delete the old object, so in every update to my document, I get a new copy of all the content in the database.

      Is this the normal behavior? I'd like to either, use the same record for the update or to generate a new one, but delete the old one, since it's no longer needed.