-
Notifications
You must be signed in to change notification settings - Fork 106
Closed
Description
When dealing with subviews containing subqueries, it would be useful to be able to refer to the subview's context root. This fosters the independence of entity views from the view hierarchy they are used in as subquery providers can be implemented without knowing the view hierarchy. Consider the following example:
@EntityView(DocumentVersion.class)
public interface DocumentVersionView {
DocumentView getDocument();
}
@EntityView(Document.class)
public interface DocumentView {
@MappingSubquery(MyUselessSubqueryProvider.class)
public List<UselessStuff> getMeUselessStuff();
public static class MyUselessSubqueryProvider implements SubqueryProvider {
createSubquery(SubqueryInitiator init) {
init.from(UselessStuff.class, "useless")
.where("useless.documentId").eqExpression("OUTER(document.id)"); // we have to know that we are nested in DocumentVersionView
// .where("useless.documentId").eqExpression("VIEW_ROOT(id)"); -- VIEW_ROOT implicitely resolves to OUTER(document) context - the root of the DocumentView view.
}
}
}The introduction of the VIEW_ROOT keyword for this purpose is a suggestion as it is quite intuitive in my opinion. Of course, we can decide for a different term as well.
Reactions are currently unavailable