Re: UUID question
Re: UUID question
- Subject: Re: UUID question
- From: Paul Hoadley <email@hidden>
- Date: Tue, 28 Jun 2016 20:52:35 +0930
Hi Ted,On 28 Jun 2016, at 7:39 PM, Theodore Petrosky < email@hidden> wrote:
I am starting a new little project and I want to use the UUIDs. My migrations usually start up by inserting a few entities by executing some SQL.
The id column is not a ‘real’ postgresql UUID, it is a 128 bit bytea column. I figured out a way to use UUIDUtilities.generateAsNSData use that value to insert my entity.
String theSQL = "INSERT INTO person (active, firstname, creationdate, id) VALUES " + "(true, 'Ted', now(), decode(E'" + UUIDUtilities.generateAsNSData()._hexString() + "', 'hex'))"; ERXJDBCUtilities.executeUpdate(database.adaptorChannel(), theSQL);
It works, but is there a better way or more correct way to create the bytea attribute to insert.
I can’t answer your specific question (I just don’t know), but if it’s a new project, why not use PostgreSQL’s built-in UUID type? Having said that, I’ve just been browsing through Samuel Pelletier’s recent work on UUID primary keys, and perhaps that’s what you’re using here—I note that the column name you’re setting is ‘id’. In any case, for a regular attribute, it’s pretty easy to set up your model to use a PostgreSQL UUID column and a java.util.UUID on the model side. Let me know if you want a demonstration.
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >UUID question (From: Theodore Petrosky <email@hidden>) |