Support for Data Repositories

Data Repository Wizard

Studio provides a wizard for creating and managing data repositories.

To create a repository, click New → Data Repository in Jmix tool window toolbar.

data repository create

In the New Jmix Data Repository dialog, select an entity and click OK. Studio will create the repository interface extending JmixDataRepository and add @EnableJmixDataRepositories to the main application class.

data repository wizard

When a data repository is opened in the editor, Studio shows the actions panel on top with two buttons. The Add Derived Method button allows you to create a method whose query will be derived from the method name. The Add Query Method creates a method with explicitly specified JPQL query.

data repository methods

Both methods open special dialogs where you can define the query and its parameters.

find method create

For all existing methods of a repository, Studio displays a "gear" gutter icon. It allows you to adjust the method parameters, for example add sorting or fetch plan. You can also extract the query into the @Query annotation and change the method name as you like.

data repository methods gear

Data Repositories in Tool Window

Data repositories created for a particular entity are displayed in Jmix tool window in the Data Repositories section inside the entity section.

data repository tool window

Data Repositories in Views

You can easily delegate loading and saving data in views to Spring Data repositories.

When creating an entity list or detail view, select the Use Data Repositories checkbox in the Advanced section of the wizard’s first page, and choose an existing data repository from the dropdown. The wizard will generate the load and save delegates that invoke appropriate repository methods.