I've searched hi and low on the net to figure out an easy way to use an 
java.util.UUID type as record id. As this is a MariaDB instance I used a 
binary(16) field as storage.

Now on to the problem: I tried using a definition of a SQLDataType.UUID 
mapping as I understood that this is internally mapped to a java.util.UUID. 
The configuration used was:

<forcedType>

  <name>UUID</name>

 <expression>(?i:.*\..*_uuid)$/expression>

</forcedType>


Generated code did compile but fetching data always resulted in NULL values 
instead of the correctly stored UUIDs (and yes newRecord/store did work). A 
little debugging showed that default converter was trying to parse a String 
into a UUID and obviously the regex matcher didn't work on the binary data.

Switching to a 

<customType>

  <name>java.util.UUID</name>

 <converter>org.zbra.domain.UUIDConverter</converter>

</customType>

and 

<forcedType>

 <name>java.util.UUID</name>

 <expression>(?i:.*\..*_uuid)$/expression>
</forcedType>

implementing very straight forward

import org.jooq.Converter;

import java.nio.ByteBuffer;
import java.util.UUID;

public class UUIDConverter implements Converter<byte[], UUID> {

private static final long serialVersionUID = 8213839434240264996L;

@Override
public UUID from(byte[] bytes) {

did work and fetching now returns correct values.

Was my assumption wrong that SQLDataType.UUID can be mapped to a 
binary(16)? Or how would it have to be configured? Feels to me that I 
rewrote boiler plate code...

  

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to