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 "hibernate.properties" available at the root of the classpath:

hibernate.jdbc.use_streams_for_binary=true
hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
(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 !)

0 comments



http://www.macosxguru.net/article.php?story=20120116143052547