Jump to: navigation, search

EclipseLink/UserGuide/JPA/Basic JPA Development/Entities/Ids/UuidGenerator

< EclipseLink‎ | UserGuide‎ | JPA‎ | Basic JPA Development
Revision as of 11:42, 28 June 2012 by James.sutherland.oracle.com (Talk | contribs) (New page: {{EclipseLink_UserGuide |info=y |toc=n |eclipselink=y |eclipselinktype=JPA |api=y |apis= *[http://www.eclipse.org/eclipselink/api/latest/javax/persistence/GeneratedValue.html @GeneratedVal...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

EclipseLink JPA

Mailing ListForumsIRCmattermost
OpenHelp WantedBug Day
Browse Source


You can use the @UuidGenerator to generate an object's Id based on a Universally Unique IDentifier (UUID). A UUID is a globally unique id. A UUID does not require database access, so is efficient to generate, but is a large value, so requires more storage than a numeric id. A UUID can be stored as a String (32 bytes) or a byte[] (16 bytes). UUIDs are useful in distributed architectures as they do not require a single id generator node.

Attribute Description Default Required?
name The name of the generator must match the name of a GeneratedValue. Yes

The following example shows how to use this annotation to specify the allocation size for the SEQUENCE primary key generator named Emp_Seq.

Example: @UuidGenerator
 public class Employee implements Serializable {
     public String getId() {
         return id;
Example: Using <sequence-generator>
<entity class="Employee">
        <id name="id">
            <column name="EMP_ID"/>
            <generated-value generator="UUID"/>
            <uuid-generator name="UUID"/>

Version: 2.4 DRAFT
Other versions...