Are views internally use JPA 2.1 Entity Graph?

Hi,

here’s a little question: Is the views mechanism based on the JPA 2.1 Entity Graph spec? I already read that it uses eclipselink’s features to allow that feature, i was just curious if it uses the official JPA APIs for that. I can remember that in CUBA 6.x OpenJPA was replaced by eclipselink. Did this change had anything to do with feature?

In case it is based on JPA, would it theoretical be possible to switch to Hibernate? Because if i get it correctly it also implements JPA 2.1.
Additional question: Would it be possible to instead of using views.xml the annotation based approach with javax.persistence.NamedEntityGraph?

This are all just theoretical questions. Neither i’m interested in switching the OR-Mapper nor that i would care :slight_smile:

Bye
Mario

Hi Mario,

The short answer is no, CUBA does not use the JPA 2.1 Entity Graph spec because it specifies only loading of related entities, while we need separate loading for each attribute - so called “partial entity”. Hibernate does not support it, so it’s not an option.

From our experience, partial entities give much better performance in an average enterprise application with entities having many attributes, especially when loading lists of entities for UI.

Both EclipseLink and OpenJPA allows you to load partial entities through their mechanisms of FetchGroups or FetchPlans. We wrap this mechanism of EclipseLink in our views and add some heuristics to provide best fetch modes depending on the situation, see FetchGroupManager.

1 Like

Hi Konstantin,

thanks for clarification. I thought the Entity Graph of JPA does exactly describe what you meant by “Partial entity” - but you are right, i was wrong on that.

Bye
Mario