Create Task List

Now that we have our Task entity, let's create the TaskList entity which will represent a collection of tasks.

First, we'll create a new class TaskList in our entities package and mark it as an entity with the @Entity annotation. We'll also use the @Table annotation to specify the table name in the database:

@Entity @Table(name = "task_lists") public class TaskList { }

The id Instance Variable

Like our Task entity, we'll use a UUID for the id and mark it with @Id, @GeneratedValue, and @Column annotations:

@Id @GeneratedValue(strategy = GenerationType.UUID) @Column(name = "id", updatable = false, nullable = false) private UUID id;

The Title and Description Instance Variables

Next, we'll add the title and description fields. The title is required while the description is optional:

@Column(name = "title", nullable = false) private String title; @Column(name = "description") private String description;

The Created and Updated Instance Variables

Finally, we'll add our audit fields for tracking when the TaskList was created and last updated:

@Column(name = "created", nullable = false) private LocalDateTime created; @Column(name = "updated", nullable = false) private LocalDateTime updated;

Class Boilerplate

Like with our Task entity, we'll need to generate constructors, getters, setters, equals, hashcode and toString methods. Use your IDE's generation capabilities to create:

  1. A no-args constructor
  2. An all-args constructor
  3. Getters and setters for all fields
  4. equals and hashCode methods (based on all fields)
  5. toString method

However, let’s not do this now, as you may have noticed than we’ve not referenced Task anywhere in our TaskList class.

Let’s focus on setting up the relationship between Task and TaskList next.

Summary

  • We created the TaskList entity with most required fields and JPA annotations
  • We added audit fields for tracking creation and updates
© 2026 Devtiro Ltd. All rights reserved