hibernate / hibernate-reactive

A reactive API for Hibernate ORM, supporting non-blocking database drivers and a reactive style of interaction with the database.
https://hibernate.org/reactive
Apache License 2.0
441 stars 92 forks source link

@Lob byte[] on DB2 #306

Open gavinking opened 4 years ago

gavinking commented 4 years ago

For @Lob @Column(length = 100_000) protected byte[] pic I get the following error:

io.vertx.core.impl.NoStackTraceThrowable: Parameter at position[1] with class = [io.vertx.core.buffer.impl.BufferImpl] and value = [hello world] can not be coerced to the expected class = [io.netty.buffer.ByteBuf] for encoding.

This looks like something fixable.

gavinking commented 4 years ago

OK, so in io.vertx.db2client.impl.drda.ClientTypes we have:

case ClientTypes.BLOB:
            return clazz == byte[].class ||
                   ByteBuf.class.isAssignableFrom(clazz);

So there doesn't seem to be any support for Buffer there.

But if you look in the DataTypeCodec classes for Postgres and MySQL, they both map BYTEA/BLOB to Buffer.

CC: @aguibert

gavinking commented 4 years ago

Just discovered that this is also the reason UUIDGeneratorTest fails on DB2.

aguibert commented 4 years ago

I wanted to keep the io.vertx.db2client.impl.drda free of any Vertx dependencies, so that I could eventually split it out to write other DB2 clients with that code in the future if needed. Since Buffer is Vertx class I think I checked for it a layer up from that method. In any case, for BLOB to actually work I'd need to implement a lot more code in the codec layer, so unfortunately it would be much more involved than just fixing this codepath.

gavinking commented 4 years ago

I wanted to keep the io.vertx.db2client.impl.drda free of any Vertx dependencies, so that I could eventually split it out to write other DB2 clients with that code in the future if needed. Since Buffer is Vertx class I think I checked for it a layer up from that method.

I don't think so, or we wouldn't be seeing this error.

In any case, for BLOB to actually work I'd need to implement a lot more code in the codec layer, so unfortunately it would be much more involved than just fixing this codepath.

Yes I saw that now, but it's not just BLOB this problem applies to: the same thing happens with BINARY.

gavinking commented 4 years ago

Just discovered that this is also the reason UUIDGeneratorTest fails on DB2.

@aguibert check out the above test, where the failure has nothing to do with LOBs.