The reason being for performance reasons. I am opposed to the idea as CHAR is working just fine for us, and the small amount of records in these tables will not be affected by the additional length of a CHAR, and currently there's no difference in read times. Unfortunately, the change is not my call.
You are correct about the complications this brings. Fortunately, I have facilitated a save() method that all entities inherit and that's how MOST entities are inserted/updated. Like you mentioned, I had set the generator to "assigned" and create my UUIDs manually and do their binary conversion. This works great for inserting. Now even nastier conversions need done just to read data. I'd say likely entityloadByPK() will no longer work.
public struct function save () {
var results = validate();
if (results.isValid) {
// convert the ID if it's MySQL BINARY
if (structKeyExists(getIdentityProperty(), "mysqltype") && getIdentityProperty().mysqltype == "binary") {
var uuid = createObject("java", "java.util.UUID");
var bb = createObject("java", "java.nio.ByteBuffer").allocate(16);
var id = "";
var isNewEntity = isNull(getIdentityValue());
// assign new UUID if it's not set
if (isNull(getIdentityValue())) {
id = uuid.randomUUID();
// convert from existing binary representation
} else if (isBinary(getIdentityValue())) {
id = uuid.nameUUIDFromBytes(getIdentityValue());
// convert from existing string representation
} else {
id = uuid.fromString(getIdentityValue());
}
bb.putLong(id.getMostSignificantBits()).putLong(id.getLeastSignificantBits());
local.methodName = this["set#getIdentityPropertyName()#"];
methodName(bb.array());
}
transaction {
if (isNewEntity) {
ormGetSession().save(this, getIdentityValue());
} else {
entitySave(this);
}
}
if (structKeyExists(getIdentityProperty(), "mysqltype") && getIdentityProperty().mysqltype == "binary" && isBinary(getIdentityValue())) {
local.methodName = this["set#getIdentityPropertyName()#"];
methodName(createObject("java", "java.util.UUID").nameUUIDFromBytes(getIdentityValue()).toString());
}
}
return results;
}