I have tried it.
I get the same Exception.
- I have double checked that I really override the setJdbcObject(...) method
with..verride (JDK 1.5).
- I have also logged every BlobType method call.
Results:
- on inserts: *NO* BlobType method is called
- on selects: materializeObject(ResultSet rs, int index, int type) is called
- getClassName() is always called on registration of the BlobType.
- selects still work fine
- inserts still don't work.
Oscar
--- Andrus Adamchik <andru..bjectstyle.org> wrote:
>
> > 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.
>
> Yeah, we would probably need to do a switch to oid as our Blob
> default. I got the same comment from PostgreSQL folks in an unrelated
> discussion.
>
> As for your error, I suspect this has something to do with the fact
> that streaming
>
> As for your error... Try also overriding "setJdbcObject" in you type,
> and doublecheck that the type passed is actually BLOB and if not
> change it to BLOB:
>
> public void setJdbcObject(
> PreparedStatement st,
> Object val,
> int pos,
> int type,
> int precision) throws Exception {
>
> if(type != java.sql.Types.BLOB) {
> System.err.println("Expected BLOB, got this: " + type);
> type = java.sql.Types.BLOB;
> }
>
> st.setObject(pos, val, type);
> }
>
> This might fix your problem, and may give us more information if this
> is indeed a glitch in Cayenne.
>
> Andrus
>
> On Oct 2, 2005, at 4:13 PM, Oscar Picasso wrote:
> > 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 - 17:00:45 EDT