Thanks very much for that Gordon, the PrePersist event is exactly what I
was looking for and enlightened me to quiet a few other things as well.
Thanks so much for taking the time to explain this as I am aware this
might be outside the scope of this user list.
You guys rock!
Kenneth Clark
Developer / Analyst
Rabid Dog Laboratories ^(TM)
Putting the art back into development
*tel:* +27 11 475 7409
*mobile:* +27 82 500 5090
*e-mail:* kenneth_at_rabiddog.co.za
*website:*
http://www.rabiddog.co.za/
Gordon Yorke wrote:
> Hello Kenneth,
> Yes a GUID can be used as the PK value for an entity. I would
> recomend storing it in the Entity in the form of a string.
> How you get the GUID generated and into the Entity is a much
> tougher problem. If you are on a database that supports GUID
> generation through the native sequence mechanism then configure the
> sequence on the database and configure TopLink to use that sequence
> through the Java Persistence APIs.
> The easiest alternative would be to have your application generate
> the GUIDs and set them in the Entity on creation of the Entity or
> within a prePersist event.
> You could create a GUID Sequence type for TopLink, create a
> sequence using this new Sequence Type and configure the TopLink
> descriptor to use this sequence.
> If you are on a database that supports identity fields you could
> write a trigger that generates the GUID on insert and configure
> TopLink to use IDENTITY sequencing through the Java Persistence APIs.
> If all of your classes would be using GUIDs on a database that
> does not support identity fields the database platform in TopLink
> could be configured to support trigger generated GUIDs through custom
> configuration.
> --Gordon
>
> -----Original Message-----
> *From:* Kenneth Clark [mailto:kenneth_at_rabiddog.co.za]
> *Sent:* Wednesday, January 24, 2007 6:47 AM
> *To:* users_at_glassfish.dev.java.net
> *Subject:* Entity auto generated id
>
> This might be a really weird question so please forgive me
>
> Is there anyway to auto generate a unique ID using a custom
> routine for the record?
>
> i.e.: I would like to use a GUID as the PK value for an entity. Is
> this possible?
>
> Thanks
>
> --
> Kenneth Clark
> Developer / Analyst
>
> Rabid Dog Laboratories ^(TM)
> Putting the art back into development
>
> *tel:* +27 11 475 7409
> *mobile:* +27 82 500 5090
> *e-mail:* kenneth_at_rabiddog.co.za
> *website:* http://www.rabiddog.co.za/
>
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.432 / Virus Database: 268.17.8/649 - Release Date: 23/01/2007 20:40
>