materialize the manytomany relationship to have better control over queries

This commit is contained in:
Athou
2013-07-04 23:40:25 +02:00
parent d57a1c9e2a
commit 4efa18f9e6
8 changed files with 110 additions and 70 deletions

View File

@@ -16,7 +16,6 @@ import javax.persistence.criteria.Path;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.persistence.criteria.Selection;
import javax.persistence.criteria.SetJoin;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
@@ -31,6 +30,8 @@ import com.commafeed.backend.model.FeedEntryContent_;
import com.commafeed.backend.model.FeedEntryStatus;
import com.commafeed.backend.model.FeedEntryStatus_;
import com.commafeed.backend.model.FeedEntry_;
import com.commafeed.backend.model.FeedFeedEntry;
import com.commafeed.backend.model.FeedFeedEntry_;
import com.commafeed.backend.model.FeedSubscription;
import com.commafeed.backend.model.FeedSubscription_;
import com.commafeed.backend.model.Feed_;
@@ -139,8 +140,8 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
CriteriaQuery<Tuple> query = builder.createTupleQuery();
Root<FeedEntry> root = query.from(FeedEntry.class);
SetJoin<FeedEntry, Feed> feedJoin = root.join(FeedEntry_.feeds);
SetJoin<Feed, FeedSubscription> subJoin = feedJoin
Join<FeedFeedEntry, Feed> feedJoin = root.join(FeedEntry_.feedRelationships).join(FeedFeedEntry_.feed);
Join<Feed, FeedSubscription> subJoin = feedJoin
.join(Feed_.subscriptions);
Join<FeedEntry, FeedEntryContent> contentJoin = root
.join(FeedEntry_.content);
@@ -231,8 +232,8 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
CriteriaQuery<Tuple> query = builder.createTupleQuery();
Root<FeedEntry> root = query.from(FeedEntry.class);
SetJoin<FeedEntry, Feed> feedJoin = root.join(FeedEntry_.feeds);
SetJoin<Feed, FeedSubscription> subJoin = feedJoin
Join<FeedFeedEntry, Feed> feedJoin = root.join(FeedEntry_.feedRelationships).join(FeedFeedEntry_.feed);
Join<Feed, FeedSubscription> subJoin = feedJoin
.join(Feed_.subscriptions);
Selection<FeedEntry> entryAlias = root.alias("entry");
@@ -317,8 +318,8 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
CriteriaQuery<FeedEntry> query = builder.createQuery(FeedEntry.class);
Root<FeedEntry> root = query.from(FeedEntry.class);
SetJoin<FeedEntry, Feed> feedJoin = root.join(FeedEntry_.feeds);
SetJoin<Feed, FeedSubscription> subJoin = feedJoin
Join<FeedFeedEntry, Feed> feedJoin = root.join(FeedEntry_.feedRelationships).join(FeedFeedEntry_.feed);
Join<Feed, FeedSubscription> subJoin = feedJoin
.join(Feed_.subscriptions);
List<Predicate> predicates = Lists.newArrayList();
@@ -388,8 +389,8 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
CriteriaQuery<Tuple> query = builder.createTupleQuery();
Root<FeedEntry> root = query.from(FeedEntry.class);
SetJoin<FeedEntry, Feed> feedJoin = root.join(FeedEntry_.feeds);
SetJoin<Feed, FeedSubscription> subJoin = feedJoin
Join<FeedFeedEntry, Feed> feedJoin = root.join(FeedEntry_.feedRelationships).join(FeedFeedEntry_.feed);
Join<Feed, FeedSubscription> subJoin = feedJoin
.join(Feed_.subscriptions);
Selection<FeedEntry> entryAlias = root.alias("entry");