small optimizations

This commit is contained in:
Athou
2013-05-21 12:41:57 +02:00
parent a0c086de68
commit 23240f2c93
5 changed files with 21 additions and 18 deletions

View File

@@ -13,11 +13,13 @@ import com.commafeed.backend.model.FeedPushInfo_;
@Stateless
public class FeedPushInfoDAO extends GenericDAO<FeedPushInfo> {
public List<FeedPushInfo> findByTopic(String topic) {
public List<FeedPushInfo> findByTopic(String topic, boolean includeFeed) {
CriteriaQuery<FeedPushInfo> query = builder.createQuery(getType());
Root<FeedPushInfo> root = query.from(getType());
root.fetch(FeedPushInfo_.feed);
if (includeFeed) {
root.fetch(FeedPushInfo_.feed);
}
query.where(builder.equal(root.get(FeedPushInfo_.topic), topic));
TypedQuery<FeedPushInfo> q = em.createQuery(query);