4

If you have lob type

@Column(name = "xml")
@Lob
private String xml;

then in PostgreSQL you get column with type text

 \d tablename
 Column     |            Type             | Modifiers 
 ----------------+-----------------------------+-----------
 xml            | text                        | 

When you insert some text into this colummn then large object is created and column contain s link to this object

# select * from  tablename
xml
+------------
 242781
(1 row)

In this post it's suggested to use vacuumlo utility to cleanup large objects which correspond to deleted rows. But according this documentation

It then scans through all columns in the database that are of type oid or lo, and removes matching entries from the temporary table. (Note: only types with these names are considered; in particular, domains over them are not considered.)

So if you run vacuumlo on database that contains text column then all large objects will be deleted as they are referencef from text column not oid. So question how shold I map LOB object in hibernate to be allowed clean up unused space

I checked with Postgresql 9.3.4 and hibernate 4.3.5

Community
  • 1
  • 1
sasha
  • 63
  • 7
  • 1
    Hibernate used "large objects" when you use the `@Lob` annotation if I'm not mistaken (which I consider a bug, it should use `bytea` instead). Using "large objects" is in most cases the wrong choice anyway. If you are storing XML in that column, why don't you use the `xml` type? Or at least make Hibernate use `bytea` instead of `oid` –  May 08 '14 at 13:15
  • There is a work around documented here to store the value instead of using Large Objects in postgres. https://www.switch.ch/aai/guides/idp/installation/#ormxmlworkaround – Jason Hendry Nov 11 '19 at 00:21

0 Answers0