Create User Entity

In this lesson, we'll create a user entity that represents users in our ticketing platform.

Decide the Implementation Approach

While we have three distinct types of users (organizers, staff, and attendees), we'll use a single User entity rather than creating separate classes for each type.

This approach simplifies our domain model while still maintaining the flexibility to handle different user roles through Keycloak.

Create the User Entity

Let's create our User entity with the necessary fields and JPA annotations:

@Entity @Table(name = "users") @Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder public class User { @Id @Column(name = "id", updatable = false, nullable = false) private UUID id; @Column(name = "name", nullable = false) private String name; @Column(name = "email", nullable = false) private String email; // Relationships to be implemented later // TODO: Organized events // TODO: Attending events // TODO: Staffing events @CreatedDate @Column(name = "created_at", updatable = false, nullable = false) private LocalDateTime createdAt; @LastModifiedDate @Column(name = "updated_at", nullable = false) private LocalDateTime updatedAt; }

Summary

  • Created a User class to represent a user of the system
  • We'll use the same User class for attendees, staff and organizers
  • We'll model the user's permissions using roles which we can assign in Keycloak
  • Added createdAt and updatedAt audit fields
© 2026 Devtiro Ltd. All rights reserved