hibernate-reactive icon indicating copy to clipboard operation
hibernate-reactive copied to clipboard

@Lob byte[] on DB2

Open gavinking opened this issue 5 years ago • 5 comments
trafficstars

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 avatar Aug 03 '20 11:08 gavinking

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 avatar Aug 03 '20 12:08 gavinking

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

gavinking avatar Aug 03 '20 13:08 gavinking

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.

aguibert avatar Aug 03 '20 13:08 aguibert

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 avatar Aug 03 '20 14:08 gavinking

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.

gavinking avatar Aug 03 '20 14:08 gavinking