I don't understand why
if NEW.UUID IS NULL THEN
NEW.UUID = UUID();
So, as a response to comments. The correct way of storing a 36-char UUID as binary(16) is to perform the insert in a manner like:
INSERT INTO sometable (SOMECOLUMN,UUID) VALUES ("Something",UNHEX(REPLACE("3f06af63-a93c-11e4-9797-00505690773f", "-","")))
Unhex because an UUID is already a hexed value. This means retreiving the UUID can be done like:
SELECT HEX(UUID) FROM sometable;
Just in case someone comes across this thread and is unsure how this works.