Postgresql Blob/LargeObject support in Cayenne

From: Oscar Picasso (oscgoogl..ahoo.com)
Date: Sun Oct 02 2005 - 16:13:42 EDT

  • Next message: Andrus Adamchik: "Re: Postgresql Blob/LargeObject support in Cayenne"

    Hi,

    I use Cayenne with Postgresql and make an extensive use of Blobs.

    Postgresql support two types of Blobs: bytea which is the one implemented by
    Cayenne and large objects which appears in the target column as an oid.

    I want to use the large object implementation which is more suited for really
    large blobs and supports streaming.

    I have already done that with another framework (Ibatis) and so I think I
    should also be possible in Cayenne.

    I have implemented a basic ExtendedType for that purpose:

    <code>
    ...
    public final class BlobType extends AbstractType {
            
            public String getClassName() {
                    return Blob.class.getName();
            }

            public Object materializeObject(CallableStatement stmt, int index, int type)
    throws Exception {
                    return stmt.getBlob(index);
            }

            public Object materializeObject(ResultSet rs, int index, int type) throws
    Exception {
                    return rs.getBlob(index);
            }

    }
    </code>

    I then register the ExtendedType with:
    <code>
    node.getAdapter().getExtendedTypes().registerType(new BlobType());
    </code>

    It works for retrieving the blob from the db.

    However on inserts I get and exception:
    <trace>
    ...
    Caused by: org.postgresql.util.PSQLException: Unsupported Types value: 2,004
            at
    org.postgresql.jdbc2.AbstractJdbc2Statement.setObject(AbstractJdbc2Statement.java:1663)
            at
    org.postgresql.jdbc3.AbstractJdbc3Statement.setObject(AbstractJdbc3Statement.java:1435)
            at
    org.postgresql.jdbc2.AbstractJdbc2Statement.setObject(AbstractJdbc2Statement.java:1669)
            at
    org.objectstyle.cayenne.access.types.AbstractType.setJdbcObject(AbstractType.java:92)
    ...
    </trace>

    I have noticed that 2004 is the code for Types.BLOB, so I don't see what's
    wrong.

    Are there other places I need to look at?

    Note: for the inserts I use a custom Blob implementation that works fine with
    bare bone JDBC and Ibatis.

    Oscar Picasso

                    
    __________________________________
    Yahoo! Mail - PC Magazine Editors' Choice 2005
    http://mail.yahoo.com



    This archive was generated by hypermail 2.0.0 : Sun Oct 02 2005 - 16:13:43 EDT