1 Reply Latest reply on Oct 20, 2005 8:01 PM by Emmanuel Bernard

    Error when accessing BLOB with Firebird based datasource

    Leos Urban Newbie

      I have problem with my small application based on Firebird SQL datasource.
      The same code works fine with MySQL.

      Entity Bean (blob fields):

       private byte[] photo;
       private String comment;
       @Lob(type=LobType.BLOB, fetch=FetchType.EAGER)
       public byte[] getPhoto()
       return photo;
       public void setPhoto(byte[] photo)
       this.photo = photo;
       @Lob(type=LobType.CLOB, fetch=FetchType.EAGER)
       public String getComment()
       return comment;
       public void setComment(String value)
       this.comment = value;

      Insert of data (persist) works but when I run some query then I get error.
      In server.log is:
      DEBUG [org.hibernate.util.JDBCExceptionReporter] could not execute query [select ... klient0_.photo as photo0_, klient0_.comment as comment0_ from klienti klient0_ where klient0_.lastname like ? order by klient0_.lastname]
      org.firebirdsql.jdbc.FBSQLException: I/O Exception. invalid BLOB type for operation
       at org.firebirdsql.jdbc.FBBlob.getBytes(FBBlob.java:305)
       at org.hibernate.type.ByteArrayBlobType.get(ByteArrayBlobType.java:87)
       at org.hibernate.type.AbstractLobType.nullSafeGet(AbstractLobType.java:43)
       at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81)
       at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:1898)
       at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1372)
      java.io.IOException: invalid BLOB type for operation
       at org.firebirdsql.jdbc.FBBlob$FBBlobInputStream.seek(FBBlob.java:570)
       at org.firebirdsql.jdbc.FBBlob$FBBlobInputStream.seek(FBBlob.java:557)
       at org.firebirdsql.jdbc.FBBlob.getBytes(FBBlob.java:296)
       at org.hibernate.type.ByteArrayBlobType.get(ByteArrayBlobType.java:87)
       at org.hibernate.type.AbstractLobType.nullSafeGet(AbstractLobType.java:43)
      WARN [org.hibernate.util.JDBCExceptionReporter] SQL Error: 0, SQLState: HY000
      ERROR [org.hibernate.util.JDBCExceptionReporter] I/O Exception. invalid BLOB type for operation

      Database schema (automatically generated, blob columns ) is:
      PHOTO BLOB segment 80, subtype UNKNOWN CHARACTER SET NONE Nullable
      COMMENT BLOB segment 80, subtype TEXT Nullable

      My environment:
      JBOSS AS 4.0.3RC2, EJB3 RC3, FirebirdSQL 1.5 Database server, JayBird driver 1.5.6.

      It looks as Hibernate dialect (FirebirdDialect) problem.