Start course

In this course, we will learn the concepts of microservice and spring framework with a focus on Domain-Driven Design.

Learning Objectives

  • Domain-Driven Design

Intended Audience

  • Beginner Java developers
  • Java developers interested in learning how to Build and Deploy RESTful Web Services
  • Java Developers who want to develop web applications using the Spring framework
  • Java Developers who want to develop web applications with microservices
  • Java Developers who wish to develop Spring Boot Microservices with Spring Cloud


  • Basic Java knowledge

Hello there. In this video, we will talk about entity. If you're ready, let's get started. So, we mentioned in our previous lesson that there are some patterns to model our domain. These patterns, which we'll learn in this video and in our following videos, represent the policies and logic within the problem domain. They express relationships between objects and model rules, and they bind the detail of the analysis model to the code implementation model. These are the patterns that describe the elements of your model and code. So, let's begin with entity. An entity represents a concept in your domain that is defined by its identity rather than its attributes. Although an entity's identity remains fixed throughout its lifecycle, its attributes may change. An entity is responsible for defining what it means to be the same. In code, this is often achieved by overriding the equality operations of a class. An example of an entity is a product. Its unique identity won't change once it is set, but its description, price, etc, can be altered many times.

Entities are mutable as their attributes can change. The image in the slide shows the main concepts of an entity. Now, let's look at entity through a small piece of code. In this example, we have an abstract class named BaseEntity. It could also be an interface, no problem. And if you notice, we have an id property in our BaseEntity class. We also created getters and setters for id. And finally, our class called Product inherits from the BaseEntity class. From this simple piece of code, we can understand entities are objects that have an identity that allows them to duplicate themselves relative to other objects. Entity refers to objects modeled for anything on earth. The mentioned identity is the id value for each of these objects, which allows us to distinguish them from the others since the creation process is carried out unchanged. So, I think you all figured out what the entity is. Let's take a short break here, and we'll talk about the value object  in the next video. I'll see you there.


About the Author
Learning Paths

OAK Academy is made up of tech experts who have been in the sector for years and years and are deeply rooted in the tech world. They specialize in critical areas like cybersecurity, coding, IT, game development, app monetization, and mobile development.