[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - BLOB handling with Postgresql

getaceres do-not-reply at jboss.com
Tue Dec 23 04:44:37 EST 2008


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:

@Entity
public abstract class Document implements Serializable {

@Id
@GeneratedValue
protected long id;

@Lob
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.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4198226#4198226

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4198226



More information about the jboss-user mailing list