[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Forcing bytea for Blobs in Postresql

getaceres do-not-reply at jboss.com
Wed Dec 10 06:24:17 EST 2008


Hello, I'm writing a JEE application and I'm planning to support Glassfish and JBoss in their default configurations, so I need to support Toplink and Hibernate. I know that I can use Hibernate with Glassfish but I'd like my code to work in more than one JPA implementation, so using Hibernate in Glassfish would be a Plan B.

I have a table in a PostgreSQL database with a field that will store binary data. Using Toplink to generate the table, I get a field of type bytea and so, I read the data directly. This is the behavior I want since my binary field will not be very large and having it in the same table that I insert, will simplify the management for me.
When I try to run this application in Hibernate, I get an error saying that it expected the column to be of type oid while it is of type bytea. Is there a way to force Hibernate to recognize the column with its type?

I mean, there are two ways to store binary blobs in PostgreSQL, one with bytea columns and another with oid columns as specified in http://jdbc.postgresql.org/documentation/80/binary-data.html. Can I force Hibernate to use the first approach instead of the second one?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4195561#4195561

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4195561



More information about the jboss-user mailing list