Data Access

When writing backend business logic, you need to load and store data model entities in the database. This chapter describes different ways of working with entities using APIs provided by Jmix.

The main interface for CRUD (Create, Read, Update, Delete) operations on entities is DataManager. It allows you to load graphs of entities by ID or query, to save changed instances or remove them. You can use entity event listeners to perform actions on loading and saving of particular entities. DataManager maintains cross-datastore references for both JPA, DTO, and mixed entity graphs.

Most often, your application works with a single or multiple relational databases and you use JPA entities to map your database tables to Java classes. In this case, DataManager works through JpaDataStore based on EclipseLink JPA provider. This data store implementation is integrated with data access control, entity log and dynamic attributes. It is available in your project if you have the following dependency in build.gradle:

implementation 'io.jmix.data:jmix-eclipselink-starter'
When we talk about DataManager and its capabilities in this manual, we mean the most common case of working with JPA entities, if not explicitly stated otherwise.

Another option for working with JPA entities is using JPA EntityManager directly. Some framework features are not compatible with the concept of "managed" entities, therefore EntityManager has some limitations comparing to DataManager.