What is a POJO
- POJO stands for Plain Old Java Object, which is a term used to describe a Java object that does not depend on any framework, container or library outside of the core Java libraries.
Characteristics of a POJO
- Simple: A POJO should be simple, with minimal dependencies and clear and concise code.
- Accessible: POJOs are easy to access and manipulate since they do not depend on any third-party framework or library.
- Serializable: A POJO should be serializable, meaning it can be converted to a byte stream and back to an object, which is useful for things like data transfer and storage.
- Testable: POJOs are easy to test since they do not depend on any external libraries or frameworks.
- Standard: POJOs should follow standard Java conventions and be written in accordance with the JavaBeans specification.
Example of a POJO

- In this example, we can see a simple POJo that represents a person
- It has two private fields, name and age, along with getters and setters for each field.
- The constructor takes in values for the name and age fields and initializes them.
What is JPA
- JPA stands for Java Persistence API. It is a specification in the Java programming language for managing relational data in applications.
- JPA defines a set of interfaces and classes that provide a standard way to map Java objects to relational database tables and to perform common database operations such as creating, reading, updating, and deleting records.
- JPA supports object-relational mapping (ORM), which means that developers can work with Java objects in their code and JPA will handle the details of translating those objects to and from database records.
- This can simplify development by abstracting away many of the complexities of working with a relational database.
Characteristics of JPA
- Firstly you have to create an entity class that prepresents the table you want to work with
- Next, you’ll need to create a repository interface that extends the JpaRepository interface.
- Finally, you have to you can use this repository to perform CRUD operations on the “users” table. Here are some examples:
- Overall, this service class uses the UserRepository to perform CRUD operations on the “users” table.
- The createUser method creates a new user and saves it to the database.
- The getUserById method retrieves a user by their ID. The updateUserPassword method updates a user’s password