mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
query optimizations
This commit is contained in:
@@ -6,7 +6,6 @@ import javax.ejb.Stateless;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.commafeed.backend.model.Feed;
|
||||
import com.commafeed.backend.model.FeedCategory;
|
||||
import com.commafeed.backend.model.FeedSubscription;
|
||||
import com.commafeed.backend.model.User;
|
||||
import com.commafeed.frontend.utils.ModelFactory.MF;
|
||||
@@ -36,14 +35,14 @@ public class FeedSubscriptionService extends GenericDAO<FeedSubscription, Long>
|
||||
}
|
||||
|
||||
public List<FeedSubscription> findAll(User user) {
|
||||
return findByField(MF.i(MF.p(FeedCategory.class).getUser()), user);
|
||||
return findByField(MF.i(proxy().getUser()), user);
|
||||
}
|
||||
|
||||
public List<FeedSubscription> findWithoutCategories(User user) {
|
||||
EasyCriteria<FeedSubscription> criteria = EasyCriteriaFactory
|
||||
.createQueryCriteria(em, getType());
|
||||
criteria.andEquals("user", user);
|
||||
criteria.andIsNull("category");
|
||||
criteria.andEquals(MF.i(proxy().getUser()), user);
|
||||
criteria.andIsNull(MF.i(proxy().getCategory()));
|
||||
return criteria.getResultList();
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.util.Set;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
@@ -23,7 +22,7 @@ public class FeedEntry extends AbstractModel {
|
||||
@Column(length = 2048)
|
||||
private String guid;
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@ManyToOne
|
||||
private Feed feed;
|
||||
|
||||
@Column(length = 2048)
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.commafeed.backend.model;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@@ -11,10 +10,10 @@ import javax.persistence.Table;
|
||||
@SuppressWarnings("serial")
|
||||
public class FeedSubscription extends AbstractModel {
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@ManyToOne
|
||||
private User user;
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@ManyToOne
|
||||
private Feed feed;
|
||||
|
||||
@Column(length = 128)
|
||||
|
||||
@@ -61,8 +61,7 @@ public class EntriesREST extends AbstractREST {
|
||||
} else {
|
||||
FeedCategory feedCategory = null;
|
||||
if (!ALL.equals(id)) {
|
||||
feedCategory = new FeedCategory();
|
||||
feedCategory.setId(Long.valueOf(id));
|
||||
feedCategory = feedCategoryService.findById(getUser(), Long.valueOf(id));
|
||||
}
|
||||
List<FeedCategory> childrenCategories = feedCategoryService
|
||||
.findAllChildrenCategories(getUser(), feedCategory);
|
||||
@@ -75,7 +74,7 @@ public class EntriesREST extends AbstractREST {
|
||||
}
|
||||
});
|
||||
|
||||
entries.setName(ALL.equals(id) ? ALL : feedCategory.getName());
|
||||
entries.setName(ALL.equals(id) ? "All" : feedCategory.getName());
|
||||
entries.getEntries().addAll(
|
||||
buildEntries(childrenCategories, subMapping, offset, limit,
|
||||
unreadOnly));
|
||||
|
||||
Reference in New Issue
Block a user