Search code examples
mysqlvarcharunique-constraintjooq

How can I map mysql varbinary to String in jOOQ code generation


MySQL doesn't accept a value like 'foo' if the column is of type varchar with a unique index and has a value 'Foo'.

So I want to change varchar into varbinary,

But jOOQ maps varbinary to byte[] in Java,

How can I configure jOOQ to resolve this?


Solution

  • MySQL UNIQUE constraints can be case-insensitive if their underlying column's collation is case-insensitive. So, instead of changing the column data type, you should really fix the collation of the VARCHAR column. This is explained here:

    SQL unique varchar case sensitivity question