• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: UUID question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


-- 
Paul Hoadley
http://logicsquad.net/



 _______________________________________________
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>)

  • Prev by Date: UUID question
  • Next by Date: Re: UUID question
  • Previous by thread: UUID question
  • Next by thread: Re: UUID question
  • Index(es):
    • Date
    • Thread