List of usage examples for org.hibernate Query setEntity
@Deprecated @SuppressWarnings("unchecked") Query<R> setEntity(String name, Object val);
From source file:com.zutubi.pulse.master.model.persistence.hibernate.HibernateAgentSynchronisationMessageDao.java
License:Apache License
public int deleteByAgentState(final AgentState agentState) { return getHibernateTemplate().execute(new HibernateCallback<Integer>() { public Integer doInHibernate(Session session) throws HibernateException { Query queryObject = session .createQuery("delete from AgentSynchronisationMessage where agentState = :agentState"); queryObject.setEntity("agentState", agentState); return queryObject.executeUpdate(); }/*from w w w .java 2s . c o m*/ }); }
From source file:com.zutubi.pulse.master.model.persistence.hibernate.HibernateBuildResultDao.java
License:Apache License
public List<BuildResult> findSinceByProject(final Project project, final Date since) { return getHibernateTemplate().execute(new HibernateCallback<List<BuildResult>>() { public List<BuildResult> doInHibernate(Session session) throws HibernateException { Query queryObject = session.createQuery( "from BuildResult model where model.project = :project and model.user = null and model.stamps.endTime > :since order by model.number desc"); queryObject.setEntity("project", project); queryObject.setLong("since", since.getTime()); return queryObject.list(); }// www .ja v a2 s . c o m }); }
From source file:com.zutubi.pulse.master.model.persistence.hibernate.HibernateBuildResultDao.java
License:Apache License
public List<BuildResult> findLatestByProject(final Project project, final int first, final int max) { return getHibernateTemplate().execute(new HibernateCallback<List<BuildResult>>() { public List<BuildResult> doInHibernate(Session session) throws HibernateException { Query queryObject = session.createQuery( "from BuildResult model where model.project = :project and model.user = null order by model.number desc"); queryObject.setEntity("project", project); queryObject.setFirstResult(first); queryObject.setMaxResults(max); return queryObject.list(); }//from w ww .j av a2 s . co m }); }
From source file:com.zutubi.pulse.master.model.persistence.hibernate.HibernateBuildResultDao.java
License:Apache License
public BuildResult findPreviousBuildResult(final BuildResult result) { return getHibernateTemplate().execute(new HibernateCallback<BuildResult>() { public BuildResult doInHibernate(Session session) throws HibernateException { Query queryObject = session.createQuery( "from BuildResult model where model.user = null and model.project = :project and model.number < :number order by model.number desc"); queryObject.setEntity("project", result.getProject()); queryObject.setLong("number", result.getNumber()); queryObject.setMaxResults(1); return (BuildResult) queryObject.uniqueResult(); }//from w ww. j av a 2 s . com }); }
From source file:com.zutubi.pulse.master.model.persistence.hibernate.HibernateBuildResultDao.java
License:Apache License
public BuildResult findByUserAndNumber(final User user, final long number) { List<BuildResult> results = (List) getHibernateTemplate() .execute(new HibernateCallback<List<BuildResult>>() { public List<BuildResult> doInHibernate(Session session) throws HibernateException { Query queryObject = session.createQuery( "from BuildResult model where model.user = :user and model.number = :number"); queryObject.setEntity("user", user); queryObject.setParameter("number", number); return queryObject.list(); }/* www . j av a 2 s .com*/ }); if (results.size() > 1) { LOG.warning( "findByUserAndNumber has returned " + results.size() + " results when expecting at most one."); } if (results.size() > 0) { return results.get(0); } return null; }
From source file:com.zutubi.pulse.master.model.persistence.hibernate.HibernateBuildResultDao.java
License:Apache License
public int getCompletedResultCount(final User user) { return toInt(getHibernateTemplate().execute(new HibernateCallback<Long>() { public Long doInHibernate(Session session) throws HibernateException { Query queryObject = session.createQuery( "select count (*) from BuildResult model where model.user = :user and model.stateName in (:stateNames)"); queryObject.setEntity("user", user); queryObject.setParameterList("stateNames", getStateNames(ResultState.getCompletedStates())); return (Long) queryObject.uniqueResult(); }//w w w .j a va2 s.c o m })); }
From source file:com.zutubi.pulse.master.model.persistence.hibernate.HibernateBuildResultDao.java
License:Apache License
public List<BuildResult> getOldestCompletedBuilds(final User user, final int offset) { int count = getCompletedResultCount(user); if (count > offset) { final int max = count - offset; return getHibernateTemplate().execute(new HibernateCallback<List<BuildResult>>() { public List<BuildResult> doInHibernate(Session session) throws HibernateException { Query queryObject = session.createQuery( "from BuildResult model where model.user = :user and model.stateName in (:stateNames) order by model.number asc"); queryObject.setEntity("user", user); queryObject.setParameterList("stateNames", getStateNames(ResultState.getCompletedStates())); if (max > 0) { queryObject.setMaxResults(max); }//from ww w. j a v a 2 s . c o m return queryObject.list(); } }); } return Collections.emptyList(); }
From source file:com.zutubi.pulse.master.model.persistence.hibernate.HibernateBuildResultDao.java
License:Apache License
public BuildResult findByRecipeId(long id) { final RecipeResultNode node = findResultNodeByResultId(id); if (node == null) { return null; }// w w w. ja v a 2 s. co m return getHibernateTemplate().execute(new HibernateCallback<BuildResult>() { public BuildResult doInHibernate(Session session) throws HibernateException { Query queryObject = session.createQuery( "select result from BuildResult result join result.stages stage where stage = :node"); queryObject.setEntity("node", node); return (BuildResult) queryObject.uniqueResult(); } }); }
From source file:com.zutubi.pulse.master.model.persistence.hibernate.HibernateChangelistDao.java
License:Apache License
public int getSize(final PersistentChangelist changelist) { return toInt(getHibernateTemplate().execute(new HibernateCallback<Long>() { public Long doInHibernate(Session session) throws HibernateException { Query queryObject = session.createQuery( "select count(change) from PersistentChangelist model join model.changes as change where model = :changelist"); queryObject.setEntity("changelist", changelist); return (Long) queryObject.uniqueResult(); }/*from w ww . j ava2 s. c om*/ })); }
From source file:com.zutubi.pulse.master.model.persistence.hibernate.HibernateProjectDao.java
License:Apache License
@SuppressWarnings({ "unchecked" }) public List<Project> findByResponsible(final User user) { return getHibernateTemplate().execute(new HibernateCallback<List<Project>>() { public List<Project> doInHibernate(Session session) throws HibernateException { Query queryObject = session.createQuery("from Project project where responsibility.user = :user"); queryObject.setEntity("user", user); return queryObject.list(); }/*w ww . j a va 2 s.c om*/ }); }