List of usage examples for org.hibernate.criterion Projections max
public static AggregateProjection max(String propertyName)
From source file:org.encuestame.persistence.dao.imp.HashTagDao.java
License:Apache License
/** * Get max-min tag frecuency./* w ww .jav a 2s . c o m*/ * * @param tag * @param filter * @return */ @SuppressWarnings("unchecked") public List<Object[]> getMaxMinTagFrecuency() { final DetachedCriteria criteria = DetachedCriteria.forClass(HashTag.class); ProjectionList projectList = Projections.projectionList(); projectList.add(Projections.max("hits")); projectList.add(Projections.min("hits")); criteria.setProjection(projectList); return (List<Object[]>) getHibernateTemplate().findByCriteria(criteria); }
From source file:org.encuestame.persistence.dao.imp.PollDao.java
License:Apache License
public Long getMaxPollLikeVotesbyUser(final Long userId, final Date dateFrom, final Date dateTo) { DetachedCriteria criteria = DetachedCriteria.forClass(Poll.class); criteria.setProjection(Projections.max("likeVote")); criteria.createAlias("editorOwner", "editorOwner"); criteria.add(Restrictions.eq("editorOwner.uid", userId)); criteria.add(Restrictions.between("createDate", dateFrom, dateTo)); @SuppressWarnings("unchecked") List<Poll> results = (List<Poll>) getHibernateTemplate().findByCriteria(criteria); return (Long) (results.get(0) == null ? 0 : results.get(0)); }
From source file:org.encuestame.persistence.dao.imp.TweetPollDao.java
License:Apache License
public Long getMaxTweetPollLikeVotesbyUser(final Long userId) { DetachedCriteria criteria = DetachedCriteria.forClass(TweetPoll.class); criteria.setProjection(Projections.max("likeVote")); criteria.createAlias("editorOwner", "editorOwner"); criteria.add(Restrictions.eq("editorOwner.uid", userId)); @SuppressWarnings("unchecked") List<TweetPoll> results = (List<TweetPoll>) getHibernateTemplate().findByCriteria(criteria); return (Long) (results.get(0) == null ? 0 : results.get(0)); }
From source file:org.faster.orm.service.hibernate.with.property.HibernateGenericServiceWithNameAndTimestamp.java
License:Open Source License
@Override public Date findLastUpdateTime(DetachedCriteria criteria, QueryOption queryOption) { StopWatch sw = null;//from ww w. j ava2s. c om if (log.isDebugEnabled()) { log.debug("Finding {} last update time with cache {} by {}", new Object[] { persistClassName, getCacheDisplay(queryOption.isCacheEnabled()), criteria }); sw = new StopWatch(); sw.start(); } criteria.setProjection(Projections.max(getFieldNameOfTimestamp())); Date ret = (Date) fetchSingle(criteria, queryOption); if (log.isDebugEnabled()) { log.debug("{} last update time is {}. ({} ms)", new Object[] { persistClassName, ret, sw.getTime() }); } return ret; }
From source file:org.fornax.cartridges.sculptor.framework.accessimpl.jpahibernate.JpaHibFindByConditionStatAccessImpl.java
License:Apache License
private void addStatProjection(Criteria criteria) throws PersistenceException { ProjectionList projList = Projections.projectionList(); projList.add(Projections.rowCount()); for (ColumnStat<T> column : statResult) { if (column.isCountNotNullFlag()) { projList.add(Projections.count(column.getColumn().getName())); }/*from ww w . j a v a2 s .co m*/ if (column.isMinFlag()) { projList.add(Projections.min(column.getColumn().getName())); } if (column.isMaxFlag()) { projList.add(Projections.max(column.getColumn().getName())); } if (column.isAverageFlag()) { projList.add(Projections.avg(column.getColumn().getName())); } if (column.isSumFlag()) { projList.add(Projections.sum(column.getColumn().getName())); } } criteria.setProjection(projList); }
From source file:org.hoteia.qalingo.core.dao.RetailerDao.java
License:Apache License
public Long getMaxRetailerId() { Criteria criteria = createDefaultCriteria(Retailer.class); criteria.setProjection(Projections.max("id")); Long maxId = (Long) criteria.uniqueResult(); return (maxId == null) ? new Long(0) : maxId; }
From source file:org.hoteia.qalingo.core.dao.RetailerDao.java
License:Apache License
public Long getMaxStoreId() { Criteria criteria = createDefaultCriteria(Store.class); criteria.setProjection(Projections.max("id")); Long maxId = (Long) criteria.uniqueResult(); return (maxId == null) ? new Long(0) : maxId; }
From source file:org.hoteia.qalingo.core.dao.UserDao.java
License:Apache License
public Long getMaxUserId() { Criteria criteria = createDefaultCriteria(User.class); criteria.setProjection(Projections.max("id")); Long maxId = (Long) criteria.uniqueResult(); return (maxId == null) ? new Long(0) : maxId; }
From source file:org.hoteia.qalingo.core.dao.UserDao.java
License:Apache License
public Long getMaxCompanyId() { Criteria criteria = createDefaultCriteria(Company.class); criteria.setProjection(Projections.max("id")); Long maxId = (Long) criteria.uniqueResult(); return (maxId == null) ? new Long(0) : maxId; }
From source file:org.hoteia.qalingo.core.dao.WarehouseDao.java
License:Apache License
public Long getMaxWarehouseId() { Criteria criteria = createDefaultCriteria(Warehouse.class); criteria.setProjection(Projections.max("id")); Long maxId = (Long) criteria.uniqueResult(); return (maxId == null) ? new Long(0) : maxId; }