I try to use byte[] <-> Blob also.
DB : PostgresSQL 7.3.1 under Linux
My table is
create table external_docs (
ext_id int4 not null,
report_id int4 null,
name varchar(200) not null,
value bytea not null,
content_type varchar(100) null,
create_date timestamp null,
constraint pk_external_docs primary key (ext_id),
constraint fk_external_relations_report foreign key (report_id)
references report (report_id)
on delete restrict on update restrict
);
I used original BinaryBlobType example and modificated :
public void nullSafeSet(PreparedStatement st, Object value, int index)
throws HibernateException, SQLException {
final byte[] buf = (byte[]) value;
ByteArrayInputStream in = new ByteArrayInputStream(buf);
st.setBinaryStream(index, in, buf.length);
}
But still i'm getting errors like this one:
Hibernate: select nextval ('ext_doc_seq')
Hibernate: insert into external_docs (name, content_type, value, report_id, create_date, ext_id) values (?, ?, ?, ?, ?, ?)
13:48:17,098 WARN JDBCExceptionReporter:38 - SQL Error: 0, SQLState: null
13:48:17,098 ERROR JDBCExceptionReporter:46 - ERROR: column "value" is of type bytea but expression is of type integer
You will need to rewrite or cast the expression
|