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

Screenshot from the Jakarta Agentic AI webinar showing a presentation slide titled “Jakarta Agentic AI” with bullet points about vendor-neutral APIs, early project status, and a Java SE 17 and Jakarta EE 10 baseline. Video thumbnails of multiple panel speakers appear on the left, and a GitHub repository link is displayed on the slide. 2 minutes
Community

Shaping Jakarta Agentic AI Together – Watch the Open Conversation

Earlier this week, we hosted Jakarta Agentic AI, An Open Conversation, an open house Jakarta TechTalk session, exploring a […]

Blue background with coral and fish. Left text: 'MONTHLY CATCH'. Right: laptop screen with tech tabs and Payara Community logo. 5 minutes
Community

The Payara Monthly Catch – January 2026

Published a little later than usual due to a busy conference season, this edition looks back at the key […]

Blog Qube SpringBoot 4 minutes
Spring

Spring Boot 4 Is Here And Payara Qube Is Getting Ready for It 

Spring Framework 7 and Spring Boot 4 officially arrived, marking a key milestone for the Java ecosystem. From improved startup performance and modularization to native-image […]