hibernate-reactive
hibernate-reactive copied to clipboard
@Lob byte[] on DB2
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.
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
Just discovered that this is also the reason UUIDGeneratorTest fails on DB2.
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.
I wanted to keep the
io.vertx.db2client.impl.drdafree 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. SinceBufferis 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.
Just discovered that this is also the reason
UUIDGeneratorTestfails on DB2.
@aguibert check out the above test, where the failure has nothing to do with LOBs.