BinaryToUuidMapper implements TypeMapper<Object, UUID> { @Override public byte[] toDatabaseType(UUID uuid) { return ByteBuffer.allocate(16) .putLong(uuid.getMostSignificantBits()) .putLong(uuid.getLeastSignificantBits()) .array(); }  @Override String getLabel(); @Override Type getJavaType(Column column); @Override UUID toJavaType(Column column, Class<?> aClass, Object binary); @Override byte[] toDatabaseType(UUID uuid);  }
@Test void toDatabaseType() throws Exception { final byte[] expected = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, }; final ByteBuffer test = ByteBuffer.wrap(expected); final UUID original = new UUID(test.getLong(), test.getLong()); final Object actual = uuidMapper.toDatabaseType(original); assertNotNull(actual); assertEquals(byte[].class, actual.getClass(), "Result correct type: "); assertArrayEquals(expected, (byte[]) actual, "Result correct values: "); }