Perform CRUD Operations on a non-entity table


due to performance issues we maintain a separate table that pools information from the data model, that in regular circumstances takes at a single record level, several seconds to produce (several tables and joins involved). Therefore arranging a report on that segment of our data domain, takes very long, hence leveraging the option of creating through a separate batch operation, the querying and storing of that information in a single table so it can be retrieved with low latency.

My whole model is re-implemented in CUBA, but not this table, and wouldn’t like to need to migrate it, since its only purpose is the above mentioned.

Can I build screens to edit/delete rows for that table? What is the suggested approach?
Is there any CUBA facility for that?

I believe I should be able to dynamically generate the components and populate them, based all on a native query result list. But before I approach it, can anybody suggest anyother solution?

Thanks in advance.

Hi @carloscz25,

I would create a non-persistent entity:

Non-persistent – instances exist only in memory, or are stored somewhere via different mechanisms

  1. Create a non-persistent entity
  2. Generate standard screens using that entity
  3. Create a service and implement methods to load and save data for this entity
  4. Implement a load delegate (using the load method implemented in the service)
  5. Implement a commit delegate (using the save method implemented in the service)

P.S.: you can create a database view and use it to generate model (i.e.: the non-persistent entity). It would be easier because you’ll only need to implement the commit delegate.

Hope it helps.


1 Like

Hi @carloscz25, pointed the right direction towards solving your problem. I would also add a small bit about using MyBatis, which is integrated into the platform - Integration with MyBatis - CUBA Platform. Developer’s Manual. It will help you to implement custom SQL queries, map the result to non-persistent entities and modify the records later on. This may help you to implement your service for data manipulation.

You also can have a look at this project GitHub - aleksey-stukalov/github-statistics: The project demonstrates how to use external objects provided via REST API in a CUBA Application. It can give you an impression of how to define a custom load delegate along with pagination capabilities. To handle save operation define the commit delegate in your screen controller:

    @Install(target = Target.DATA_CONTEXT)
    private Set<Entity> commitDelegate(CommitContext commitContext) {
        // put your code here
        return committedEntities;


1 Like

Thanks will give it a try. Looks easy to implement.


1 Like

Thanks Aleksey will have a look at your proposal.