Results 1 to 6 of 6

Thread: For BLOB: Is there a special lobhandler for PostgreSQL

  1. #1

    Default For BLOB: Is there a special lobhandler for PostgreSQL

    or DefaultLobHandler is fine? I see there is a special handler for Oracle.

    I tried DefaultLobHandler, but it gives me error when I try to save the object: SQL error shows that I am trying to insert an expression of bytea to a oid column.

    The table is generated by using schemaexport. The code is as follows:

    /**
    * @return Returns the content.
    *
    * @hibernate.property
    * column="content"
    * type="org.springframework.orm.hibernate3.support.B lobByteArrayType"
    * update="false"
    * not-null="true"
    */
    public byte[] getContent() {
    return content;
    }
    /**
    * @param content The content to set.
    */
    public void setContent(byte[] content) {
    this.content = content;
    }


    When using spring DefaultLobHandler, unit test failed:

    [junit] [mytest] ERROR [main] JDBCExceptionReporter.logExceptions(72) | ERROR: column "content" is of type oid but expression is of type bytea


    Again, the table is generated by schemaexport - looks like it set the BLOB column to type oid.

    Any idea? Thanks.

  2. #2
    Join Date
    Aug 2004
    Posts
    1,104

    Default

    Do you have the generated DDL or could you go into psql and issue a \d 'tablename' command and post the results?
    Thomas Risberg
    SpringSource by Pivotal
    http://www.springsource.org

  3. #3

    Default

    create table blob_tb (
    id int8 not null,
    name varchar(256) not null,
    createdt timestamp not null,
    content oid not null,
    size int8 not null,
    primary key (id)
    );

  4. #4

    Default

    I gave up on Blob, just use byte[] and it works fine.

    There are two type of blob storage in postgresql: bytea and oid. Looks like hibernate schemaexport automatically uses oid based on the hbm, but spring's BlobArrayUserType uses bytea.

  5. #5
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    This comes a little too late but FYI, we have moved our app from MySQL to PostgreSQL for a client and we experienced the annoying blob problem also. We have used byte[] at Java level along with bytea for PostgreSQL and everything worked without a problem.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  6. #6

    Default

    yep, costin, that's exactly what I did. bytea holds 1G data in table - that's more than enough for me.

Similar Threads

  1. Use of LobHandler with Hibernate
    By kalgon in forum Data
    Replies: 4
    Last Post: Apr 7th, 2010, 05:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •