โดยทำตามนี้คำถามและวิธีแก้ปัญหาด้วย ฉันยังคงไม่สามารถแก้ไขปัญหาได้ ฉันยังคงได้รับ "ข้อมูลยาวเกินไปสำหรับคอลัมน์ 'id' ที่แถว 1"
public static byte[] asBytes(UUID uuid) {
ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
bb.putLong(uuid.getMostSignificantBits());
bb.putLong(uuid.getLeastSignificantBits());
return bb.array();
}
UUID id= UUID.randomUUID();
InsertQueryBuilder runner = new InsertQueryBuilder("test_table")
.addField("id", asBytes(id));
return getConnection()
.flatMap(connection -> runner.run(connection)
.doOnTerminate(connection::close))
จากคำตอบนั้นฉันเข้าใจว่า 16 ไบต์มีเลขฐานสิบหก 32 หลัก ดังนั้นหากฉันเปลี่ยนประเภทคอลัมน์เป็น BINARY (32) ฉันจะไม่ได้รับข้อผิดพลาดใด ๆ และ id จะถูกเขียนในฐานข้อมูลสำเร็จ
ฉันพยายามรักษาขนาด ByteBuffer bb ไว้ที่ 8 แต่แล้วฉันก็ได้
BufferOverflowException
ฉันพลาดอะไรไป?
long
- person Adriano Repetti   schedule 21.05.2018