Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow entity views to contain subviews with custom correlation #108

Closed
beikov opened this issue Feb 28, 2015 · 5 comments
Closed

Allow entity views to contain subviews with custom correlation #108

beikov opened this issue Feb 28, 2015 · 5 comments
Assignees
Milestone

Comments

@beikov
Copy link
Member

beikov commented Feb 28, 2015

The idea is to allow an attribute on an entity view to be computed by a subquery. The subquery would be executed for every entity view object created.
This is also kind of related to #52 since we might want to specify whether the subquery should do batching or so.

@beikov beikov self-assigned this Feb 28, 2015
@beikov beikov added this to the 1.1.0 milestone Feb 28, 2015
@beikov beikov modified the milestones: 1.2.0, 1.1.0 Jun 5, 2015
@beikov
Copy link
Member Author

beikov commented Jun 14, 2016

An entity view could contain a subview and the mapping in the main entity view would contain the correlation predicate. Something like the following.

@EntityView(Document.class)
public interface DocumentView {
//...
@MappingSubview(DocumentPermissionCorrelator.class)
public List<PermissionView> getPermissions();
//..
}

public class DocumentPermissionCorrelator implements SubviewCorrelator {

public void applyCorrelation(BaseQueryBuilder<T, ?> queryBuilder, String correlatedAlias);
  queryBuilder.from(SomeEntity.class, "someEntity");
  queryBuilder.where("someEntity.documentId").eqExpression("OUTER(id)");
  queryBuilder.where("someEntity.groupId").eqExpression(correlatedAlias + ".groupId");
}

}

@EntityView(Permission.class)
public interface PermissionView {
//...
}

Maybe the BaseQueryBuilder is an overkill in this case and we should provide a dedicated interface consisting of just FromBuilder and WhereBuilder or parts of them in a different form. This could allow several strategies for fetching the the subview like proposed in #52

  • JOIN
  • SUBQUERY
  • SUBSELECT

To get LEFT JOIN semantics in case of JOIN fetching requires to rewrite some of the predicates because in JPA2-means it can only do a CROSS JOIN to implement this feature.
Another possible implementation would be to rely on the proprietary extensions of

which would require some extensions to the core parts.

@beikov beikov changed the title Allow entity views to use subqueries for complex objects Allow entity views to contain subviews with custom correlation Jun 14, 2016
beikov added a commit that referenced this issue Sep 8, 2016
@beikov
Copy link
Member Author

beikov commented Sep 9, 2016

JOIN requires #222

beikov added a commit that referenced this issue Sep 10, 2016
@beikov
Copy link
Member Author

beikov commented Sep 13, 2016

Note that batching with SUBQUERY strategy requires #181 and entity joins from #222

beikov added a commit that referenced this issue Dec 2, 2016
@beikov
Copy link
Member Author

beikov commented Dec 2, 2016

Only the subselect strategy is missing now

@beikov
Copy link
Member Author

beikov commented Dec 7, 2016

Preparations finished for subselect fetching by 60bbe47

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant