RE: UUIDGenerator (Was External Model Mappings)

Not to derail at all (I really like this conversation) but I'm about
to start implementing a bunch of GUID-related work in an app I'm
developing. Would you mind sharing the work you have so far with
UUIDGenerator, Brad?

Sure. Pretty simple really. We create a GUID to uniquely identify each
object we create in memory. If that object gets saved to the DB, we use
that guid as the primary key value etc. Basically, the CreateUUID
function is horrendously slow if you plan on calling it more than about
4 times a day and not only that, it will screw with your system clock:

We found this post from Joe Rinehart:

that showed us the UUIDGenerator jar. All we did was drop it in the
class path (lib folder) for ColdFusion, create an instance of it in a
singleton GUID Service in my model that is injected into my base bean

<cfset variables.UUIDGenerator = createObject("java",

Then I made a simple method called CreateFastUUID that does this:

return variables.UUIDGenerator.generateRandomBasedUUID().toString();

It has worked quite well and runs literally thousands of times faster
than CF's createUUID function. If you have any operation that will be
creating hundreds or thousands of GUIDs you'll want to check it out.


Thanks Brad,

I didn't know about the CreateUUID() issue


Another alternative is to use the embedded UUID in the jvm:

createObject(“java”, “java.util.UUID”).randomUUID()