-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: BLOB handling with Postgresql
PostPosted: Mon Dec 22, 2008 1:33 pm 
Newbie

Joined: Wed Dec 10, 2008 6:39 am
Posts: 6
Hello, I'm developing an application using JBoss 4.2.3 (and hence Hibernate 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<T> implements Serializable {

@Id
@GeneratedValue
protected long id;

@Lob
protected byte[] content;

protected String username;

....................
getters and setters
....................
}

I'm using PostgreSQL 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.


Top
 Profile  
 
 Post subject: Re: BLOB handling with Postgresql
PostPosted: Thu Jul 01, 2010 6:22 pm 
Beginner
Beginner

Joined: Mon Jun 28, 2010 1:02 pm
Posts: 21
getaceres wrote:
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.


I'm not an expert, but AFAIK this is "normal". So if you delete a row, which has a BLOB with an OID, the corresponding TOAST structures and data won't be deleted. You have to take care of this yourself AFAIK. Search for lo_manage manage function and triggers on google to get more info on that. Currently I'm trying to define the triggers, but I experience problems during persist:
https://forum.hibernate.org/viewtopic.php?f=1&t=1005584


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.