JPA Entity
- The Java Persistence API (JPA), part of the Java Enterprise.
- Provides an object-relational mapping approach that lets you declaratively define how to map Java objects to relational database tables in a standard.
- Entities represent persistent data stored in a relational database automatically using container-managed persistence.
- They are persistent because their data is stored persistently in some form of data storage system, such as a database: they do survive a server failure, failover, or a network failure.
POJO
- In software engineering, a plain old Java object (POJO) is an ordinary Java object, not bound by any special restriction.
ORM
- Object-Relational Mapping or ORM is a technique for converting data between Java objects and relational databases.
- ORM converts data between two incompatible type systems (Java and MySQL), such that each model class becomes a table in our database and each instance a row of the table.
Data Layer architecture
- The data tier provides functionality to access and manage data. The data tier contains a data store for persistent storage, such as an RDBMS. It provides services and data for the business tier.
- There are variations of n-tier architectures that go beyond just three tiers. For example, in some systems, there is a data access or persistence layer in addition to a data or database layer.
- The persistence layer contains components for data access, such as an object-relational mapping (ORM) tool, and the database layer includes the actual data store, such as an RDBMS. One reason to separate these into two distinct layers is if you wanted the ability to switch out your data access or database technology for a different one.
ORM
- Object-relational-mapping is the idea of being able to write queries like the one above, as well as much more complicated ones, using the object-oriented paradigm of your preferred programming language.
- Long story short, we are trying to interact with our database using our language of choice instead of SQL.
Characteristics:
- Simplified development because it automates object-to-table and table-to-object conversion, resulting in lower development and maintenance costs.
- Less code compared to embedded SQL and handwritten stored procedures Transparent object caching in the application tier, improving system performance An optimized solution making an application faster and easier to maintain.
- ORM’s emergence in multiple application development has created disagreement among experts. Key concerns are that ORM does not perform well and that stored procedures might be a better solution. In addition, ORM dependence may result in poorly-designed databases in certain circumstances.
Examples:
Your relational data. Objectively. – Hibernate ORM
Idiomatic persistence for Java and relational databases.
Entity relationship with JPA
One-to-One Relationship in JPA | Baeldung
Learn three different ways to maintain a one-to-one relationship with JPA.
Hibernate One to Many Annotation Tutorial | Baeldung
In this tutorial we’ll have a look at the one-to-many mapping using JPA annotations with a practical example.
Many-To-Many Relationship in JPA | Baeldung
Learn how to model a many-to-many relationship in Java using JPA
Example Data Layer
GitHub – una-eif411-progra-mobile-master/backend-taskapp at DataLayer
Backend of the ToDo App. Contribute to una-eif411-progra-mobile-master/backend-taskapp development by creating an account on GitHub.
External Resources
The DAO Pattern in Java | Baeldung
Learn how to implement the Data Access Object (DAO) pattern in Java to isolate the persistence and business layers of your application.