Creating Dynamic Entity Views with Blazebit Persistence

149 Views Asked by At

I'm working with Blazebit and am looking into creating dynamic views for my entities. For instance, I have an Order entity with various fields.

public class Order {

private String id;
private List<Product> products;
private User owner;

//Getter and Setter
}

In some queries, I need to retrieve Order with its products, and in others, Order with products and the owner. Of course, I can create separate views for each scenario, but as the structure becomes more complex, the number of required views increases substantially. Is there a way to dynamically create views that can adapt based on the query requirements? Any guidance or examples would be greatly appreciated.

Thank you!

1

There are 1 best solutions below

0
Christian Beikov On

It sounds like you should be using the GraphQL integration which can handle all this out of the box.

You can use the fetch() API to fetch only a subset of your Entity Views, but I would recommend you to either use GraphQL or define dedicated Entity Views as you will figure out that you mostly have only 2-4 different views on your data anyway.