queries tweaking

This commit is contained in:
Jeremie Panzer
2013-03-27 11:32:22 +01:00
parent d603eb1773
commit 6ab93ed9d5
4 changed files with 33 additions and 11 deletions

View File

@@ -17,8 +17,7 @@ import com.uaihebert.factory.EasyCriteriaFactory;
import com.uaihebert.model.EasyCriteria;
@SuppressWarnings("serial")
public abstract class GenericDAO<T, K> implements
Serializable {
public abstract class GenericDAO<T, K> implements Serializable {
private TypeToken<T> type = new TypeToken<T>(getClass()) {
};
@@ -88,8 +87,7 @@ public abstract class GenericDAO<T, K> implements
}
public List<T> findByField(String field, Object value) {
EasyCriteria<T> criteria = EasyCriteriaFactory.createQueryCriteria(em,
getType());
EasyCriteria<T> criteria = createCriteria();
criteria.andEquals(field, value);
return criteria.getResultList();
}
@@ -98,8 +96,8 @@ public abstract class GenericDAO<T, K> implements
protected Class<T> getType() {
return (Class<T>) type.getRawType();
}
public EasyCriteria<T> createCriteria(){
public EasyCriteria<T> createCriteria() {
return EasyCriteriaFactory.createQueryCriteria(em, getType());
}

View File

@@ -29,6 +29,9 @@ public class Feed extends AbstractModel {
@OneToMany(mappedBy = "feed")
private Set<FeedEntry> entries = Sets.newHashSet();
@OneToMany(mappedBy = "feed")
private Set<FeedSubscription> subscriptions;
public Feed() {
}
@@ -69,4 +72,12 @@ public class Feed extends AbstractModel {
this.message = message;
}
public Set<FeedSubscription> getSubscriptions() {
return subscriptions;
}
public void setSubscriptions(Set<FeedSubscription> subscriptions) {
this.subscriptions = subscriptions;
}
}

View File

@@ -24,6 +24,9 @@ public class FeedCategory extends AbstractModel {
@ManyToOne
private FeedCategory parent;
@OneToMany(mappedBy = "parent")
private Set<FeedCategory> children;
@OneToMany(mappedBy = "category")
private Set<FeedSubscription> subscriptions;
@@ -62,4 +65,12 @@ public class FeedCategory extends AbstractModel {
this.subscriptions = subscriptions;
}
public Set<FeedCategory> getChildren() {
return children;
}
public void setChildren(Set<FeedCategory> children) {
this.children = children;
}
}