Using UUID As Entity Primary Key In Jakarta EE 10

Jakarta EE

In prior versions of Jakarta EE, the use of UUID as entity ID or database primary key type was a vendor specific feature. So even though you could use it, you had to rely on vendor specific constructs to get the mapping right. With the release of Jakarta EE 10 however, the Jakarta Persistence specification now provides native support for using UUID as entity ID type.

The jakarta.persistence.GenerationType now has a UUID option that indicates to the persistence provider to generate and assign RFC 4122 UUID to the annotated field. The HelloEntity below shows how to use this new feature.

@Entity
public class HelloEntity implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.UUID)
    private UUID id;
    private String greeting;
}

The strategy parameter of the @GeneratedValue annotation is passed the GenerationType.UUID type. With this, you now have a vendor neutral, portable way to entity IDs to the UUID type. 

Read more of our Jakarta EE content:

 

Comments (0)

Post a comment

Your email address will not be published. Required fields are marked *

Payara needs the contact information you provide to us to contact you about our products and services. You may unsubscribe from these communications at any time. For information on how to unsubscribe, as well as our privacy practices and commitment to protecting your privacy, please review our Legal & Privacy Policy.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Posts

SpringBoot Actuator Health for Microprofile Developers 7 minutes
Cloud & Microservices

Spring Boot Actuator Health for MicroProfile Developers

If you worked with MicroProfile Health, you already understand the value of exposing application health information through standardized endpoints. […]

Webinar banner for “High-Frequency Trading on Jakarta EE: GC Stress Testing with Azul C4 and Payara Micro,” March 25, 2026, 2 PM GMT. Features Azul and Payara Micro logos and speaker photos of Luqman Saeed, Jakarta EE Specialist, and Simon Ritter, Deputy CTO and Java Champion. 1 minute
Cloud & Microservices

High-Frequency Trading on Jakarta EE: Join Our Upcoming Live Webinar

Modern high-frequency trading (HFT) platforms operate under extreme performance constraints, processing tens of thousands of messages per second while […]

Illustration promoting the Payara Platform Community Survey, featuring bold text on a blue background alongside a clipboard with a checklist, star ratings, and check marks, with coral and fish graphics in an underwater theme. 1 minute
Community

Help Shape the Future of Payara Platform Community – Take Our 2026 Survey

Earlier this week, we’ve launched the 2026 Payara Platform Community Survey and we’d love to hear from you. If […]