Tuesday, September 25, 2018

Hibernate - @Lob with PostgreSQL


In Java, if you declare

@Lob
@Column(name = "Remark")
protected String Remark;

Hibernate will generate the column as Text data type.

CREATE TABLE public.sometable
(
    id integer NOT NULL DEFAULT ,
    remark text COLLATE pg_catalog."default",
 )

Everything is good so far, however, when you query the database with select statement (e.g select * from sometable), it will show



In my test case, all remark column are empty string. So, what are those numbers? These numbers are the UID of the LOB for each remark. In order to view the original text, one may need to run


select id, convert_from(loread(
      lo_open(remark::int, x'40000'::int), x'40000'::int), 'UTF-8')
  AS remark from mission


LDAP - Deleting an LDAP entry

To delete an ldif entry, one way is to put an changetype attribute and a value 'delete' in the ldif file For example dn: cn=so...