List of usage examples for org.hibernate Query setEntity
@Deprecated @SuppressWarnings("unchecked") Query<R> setEntity(String name, Object val);
From source file:fr.mael.microrss.dao.impl.UserArticleDaoImpl.java
License:Open Source License
@Override public List<UserArticle> getForLabel(UserLabel label, int start, int nb) { StringBuffer query = new StringBuffer("select ua from UserArticle ua "); query.append("left join fetch ua.userLabels "); query.append("inner join ua.userLabels ul "); query.append("where ul = :label "); Query q = getSession().createQuery(query.toString()); q.setEntity("label", label); q.setFirstResult(start);//from www. j av a 2 s .c om q.setMaxResults(nb); return (List<UserArticle>) q.list(); }
From source file:fr.mael.microrss.dao.impl.UserArticleDaoImpl.java
License:Open Source License
@Override public List<UserArticle> getStarred(User user, int start, int nb) { StringBuffer query = new StringBuffer("from UserArticle ua "); query.append("left join fetch ua.userLabels "); query.append("where ua.starred = :starred "); query.append("and ua.user = :user "); Query q = getSession().createQuery(query.toString()); q.setBoolean("starred", true); q.setEntity("user", user); q.setFirstResult(start);/*from w ww . ja v a2s .com*/ q.setMaxResults(nb); return (List<UserArticle>) q.list(); }
From source file:fr.mael.microrss.dao.impl.UserArticleDaoImpl.java
License:Open Source License
@Override public Long unreadStarred(User user) { StringBuffer query = new StringBuffer("select count(ua) from UserArticle ua "); query.append("where ua.user = :user "); query.append("and ua.read = :read "); query.append("and ua.starred = :starred"); Query q = getSession().createQuery(query.toString()); q.setEntity("user", user); q.setBoolean("read", false); q.setBoolean("starred", true); return (Long) q.uniqueResult(); }
From source file:fr.mael.microrss.dao.impl.UserArticleDaoImpl.java
License:Open Source License
@Override public Long labelUnread(User user, UserLabel label) { StringBuffer query = new StringBuffer("select count(ua) from UserArticle ua "); query.append("inner join ua.userLabels ul "); query.append("where ua.user = :user "); query.append("and ua.read = :read "); query.append("and ul = :label "); Query q = getSession().createQuery(query.toString()); q.setEntity("user", user); q.setBoolean("read", false); q.setEntity("label", label); return (Long) q.uniqueResult(); }
From source file:fr.mael.microrss.dao.impl.UserDaoImpl.java
License:Open Source License
@Override public boolean userHasArticle(User user, Article article) { StringBuffer query = new StringBuffer("select count(ua) from UserArticle ua "); query.append("where ua.user = :user and ua.article = :article "); Query q = getSession().createQuery(query.toString()); q.setEntity("user", user); q.setEntity("article", article); return check(q.uniqueResult()); }
From source file:fr.mael.microrss.dao.impl.UserDaoImpl.java
License:Open Source License
@Override public boolean userHasFeed(User user, Feed feed) { StringBuffer query = new StringBuffer("select count(uf) from UserFeed uf "); query.append("where uf.user = :user and uf.feed = :feed "); Query q = getSession().createQuery(query.toString()); q.setEntity("user", user); q.setEntity("feed", feed); return check(q.uniqueResult()); }
From source file:fr.mael.microrss.dao.impl.UserDaoImpl.java
License:Open Source License
@Override public boolean userHasCategory(User user, Category category) { StringBuffer query = new StringBuffer("select count(cat) from Category cat "); query.append("where cat.user = :user and cat = :cat "); Query q = getSession().createQuery(query.toString()); q.setEntity("user", user); q.setEntity("cat", category); return check(q.uniqueResult()); }
From source file:fr.mael.microrss.dao.impl.UserDaoImpl.java
License:Open Source License
@Override public List<User> usersForFeed(Feed feed) { StringBuffer query = new StringBuffer("select user from UserFeed uf "); query.append("inner join uf.user user "); query.append("where uf.feed = :feed "); Query q = getSession().createQuery(query.toString()); q.setEntity("feed", feed); return q.list(); }
From source file:fr.mael.microrss.dao.impl.UserDaoImpl.java
License:Open Source License
@Override public boolean userHasUserArticle(User user, Integer userArticle) { StringBuffer query = new StringBuffer("select count(ua) from UserArticle ua "); query.append("where ua.user = :user and ua.id = :id "); Query q = getSession().createQuery(query.toString()); q.setEntity("user", user); q.setInteger("id", userArticle); return check(q.uniqueResult()); }
From source file:fr.mael.microrss.dao.impl.UserDaoImpl.java
License:Open Source License
@Override public boolean userHasLabel(User user, Integer userLabelId) { StringBuffer query = new StringBuffer("select count(ul) from UserLabel ul "); query.append("where ul.user = :user and ul.id = :id"); Query q = getSession().createQuery(query.toString()); q.setEntity("user", user); q.setInteger("id", userLabelId); return check(q.uniqueResult()); }