JPA @Lob and PostgreSQL

Monday, January 16 2012 @ 02:30 PM UTC

Contributed by: Admin

Lot of discussions with contradictory information on the Net about the problematic, here a quick resume of the "how to"

SQL                               Java

TEXT                             @Lob @Type(type = "org.hibernate.type.TextType")  String
oid                              @Lob java.sql.Blob 
bytea                            @Lob @Type(type = "org.hibernate.type.PrimitiveByteArrayBlobType") byte[]
and in a file named "" available at the root of the classpath:

(and "hibernate.jdbc.use_streams_for_binary" should not be a "property" in persitence.xml as you may find on many sites: this doesn't work, look at the source code of the Hibernate properties loader if you don't believe us !)