List of usage examples for javax.persistence Query executeUpdate
int executeUpdate();
From source file:org.rhq.enterprise.server.measurement.MeasurementScheduleManagerBean.java
public int disableSchedulesForContext(Subject subject, EntityContext context, int[] measurementDefinitionIds) { String measurementScheduleSubQuery = getMeasurementScheduleSubQueryForContext(subject, context, measurementDefinitionIds);/*from www . ja v a 2s . co m*/ String updateQuery = "" // + "UPDATE MeasurementSchedule " // + " SET enabled = false " // + " WHERE id IN ( " + measurementScheduleSubQuery + " ) "; Query query = entityManager.createQuery(updateQuery); int affectedRows = query.executeUpdate(); scheduleJobToPushScheduleUpdatesToAgents(context, measurementScheduleSubQuery); return affectedRows; }
From source file:org.medici.bia.dao.userhistory.UserHistoryDAOJpaImpl.java
/** * {@inheritDoc}//from w w w . ja va 2 s . co m */ @Override public Integer deleteMyHistory(User user) throws PersistenceException { String updateString = "UPDATE UserHistory set logicaldelete=true WHERE user=:user and logicalDelete=false"; Query query = getEntityManager().createQuery(updateString); query.setParameter("user", user); return query.executeUpdate(); }
From source file:org.medici.bia.dao.userhistory.UserHistoryDAOJpaImpl.java
/** * {@inheritDoc}//from www. j a v a 2 s . c o m */ @Override public Integer deleteUserHistory(User user) throws PersistenceException { String updateString = "UPDATE UserHistory set logicaldelete=true WHERE user=:user and logicalDelete=false"; Query query = getEntityManager().createQuery(updateString); query.setParameter("user", user); return query.executeUpdate(); }
From source file:org.medici.bia.dao.userhistory.UserHistoryDAOJpaImpl.java
/** * {@inheritDoc}/* w w w . j a v a2 s . com*/ */ @Override public Integer restoreMyHistory(User user) throws PersistenceException { String updateString = "UPDATE UserHistory set logicaldelete=true WHERE user=:user and logicalDelete=true"; Query query = getEntityManager().createQuery(updateString); query.setParameter("user", user); return query.executeUpdate(); }
From source file:org.medici.bia.dao.userhistory.UserHistoryDAOJpaImpl.java
/** * {@inheritDoc}// www.ja v a2s.com */ @Override public Integer restoreUserHistory(User user) throws PersistenceException { String updateString = "UPDATE UserHistory set logicaldelete=true WHERE user=:user and logicalDelete=true"; Query query = getEntityManager().createQuery(updateString); query.setParameter("user", user); return query.executeUpdate(); }
From source file:org.apache.roller.weblogger.business.jpa.JPAWeblogEntryManagerImpl.java
/** * @inheritDoc//from ww w .j a v a 2s .c o m */ public void resetAllHitCounts() throws WebloggerException { Query q = strategy.getNamedUpdate("WeblogHitCount.updateDailyHitCountZero"); q.executeUpdate(); }
From source file:com.gettec.fsnip.fsn.dao.business.impl.BusinessUnitDAOImpl.java
/** * ?/*from w ww. j a va 2s . co m*/ * ????? * @author ZhangHui 2015/6/5 * @throws DaoException */ @Override public void updateRecord(BusinessUnit buss, String licenseno) throws DaoException { try { if (buss == null || buss.getId() == null || buss.getName() == null || "".equals(buss.getName())) { throw new Exception("?"); } String sql = "UPDATE business_unit SET name = ?1, address = ?2, license_no = ?3 WHERE id = ?4"; Query query = entityManager.createNativeQuery(sql); query.setParameter(1, buss.getName()); query.setParameter(2, buss.getAddress()); query.setParameter(3, licenseno); query.setParameter(4, buss.getId()); query.executeUpdate(); } catch (Exception e) { e.printStackTrace(); throw new DaoException("BusinessUnitDAOimpl.updateRecord()-->" + e.getMessage(), e); } }
From source file:org.rhq.enterprise.server.content.RepoManagerBean.java
public boolean deletePackageVersionsFromRepo(Subject subject, int repoId, int[] packageVersionIds) { if (packageVersionIds == null || packageVersionIds.length == 0) { return true; }//from ww w . j av a 2 s . c om if (!authzManager.canUpdateRepo(subject, repoId)) { throw new PermissionException("User [" + subject + "] cannot update the repo with id " + repoId + " and therefore cannot delete package versions from it."); } ArrayList<Integer> ids = new ArrayList<Integer>(); for (int id : packageVersionIds) { ids.add(id); } Query deleteable = entityManager.createNamedQuery(PackageVersion.QUERY_FIND_DELETEABLE_IDS_IN_REPO); deleteable.setParameter("repoId", repoId); deleteable.setParameter("packageVersionIds", ids); @SuppressWarnings("unchecked") List<Integer> deleteableIds = (List<Integer>) deleteable.getResultList(); if (deleteableIds.isEmpty()) { return false; } Query deleteRepoPackageVersions = entityManager .createNamedQuery(RepoPackageVersion.DELETE_MULTIPLE_WHEN_NO_PROVIDER); deleteRepoPackageVersions.setParameter("repoId", repoId); deleteRepoPackageVersions.setParameter("packageVersionIds", deleteableIds); deleteRepoPackageVersions.executeUpdate(); Query deletePackageVersions = entityManager .createNamedQuery(PackageVersion.DELETE_MULTIPLE_IF_NO_CONTENT_SOURCES_OR_REPOS); deletePackageVersions.setParameter("packageVersionIds", deleteableIds); int deleted = deletePackageVersions.executeUpdate(); return deleted == packageVersionIds.length; }
From source file:org.medici.bia.dao.userhistory.UserHistoryDAOJpaImpl.java
/** * {@inheritDoc}//from w w w . ja v a 2s . co m */ @Override public Integer deleteMyHistory(User user, Category category) throws PersistenceException { String updateString = "UPDATE UserHistory set logicaldelete=true WHERE user=:user and category=:category and logicalDelete=false"; Query query = getEntityManager().createQuery(updateString); query.setParameter("user", user); query.setParameter("category", category); return query.executeUpdate(); }
From source file:org.medici.bia.dao.userhistory.UserHistoryDAOJpaImpl.java
/** * {@inheritDoc}/*w w w . ja va2 s . c o m*/ */ @Override public Integer deleteUserHistory(User user, Category category) throws PersistenceException { String updateString = "UPDATE UserHistory set logicaldelete=true WHERE user=:user and category=:category and logicalDelete=false"; Query query = getEntityManager().createQuery(updateString); query.setParameter("user", user); query.setParameter("category", category); return query.executeUpdate(); }