List of usage examples for javax.persistence Query executeUpdate
int executeUpdate();
From source file:org.kuali.continuity.admin.dao.jpa.UserLoginDAOImpl.java
private String approveUserLogin(final User user, final boolean isApproved, Query approveUserQuery) { // generate password String password = null;/*w ww .j av a 2 s . c o m*/ String passwordHash = ""; if (isApproved) { password = PasswordGenerator.generate(user.getFullName()); passwordHash = this.getCaseInsensitivePasswordHash(password); } // update approveUserQuery.setParameter("userId", user.getId()); approveUserQuery.setParameter("password", passwordHash); approveUserQuery.setParameter("isApproved", isApproved ? '1' : '0'); approveUserQuery.executeUpdate(); // return return password; }
From source file:org.rhq.enterprise.server.drift.JPADriftServerBean.java
@Override @TransactionAttribute(REQUIRES_NEW)//from www. j av a 2 s . c o m public int purgeOrphanedDriftFiles(Subject subject, long purgeMillis) { Query q = entityManager.createNativeQuery(JPADriftFile.NATIVE_DELETE_ORPHANED_DRIFT_FILES); q.setParameter(1, purgeMillis); int count = q.executeUpdate(); log.debug("purged [" + count + "] drift files that were orphaned (that is, no longer referenced by drift)"); return count; }
From source file:pl.datamatica.traccar.api.providers.DeviceProvider.java
private void hardDelete(Device device) { device.getUsers().clear();/*w w w.ja va 2 s . c o m*/ device.setLatestPosition(null); em.flush(); Query query = em.createQuery("DELETE FROM DeviceEvent x WHERE x.device = :device"); query.setParameter("device", device); query.executeUpdate(); em.createQuery("DELETE FROM UserDeviceStatus x WHERE x.id.device = :device").setParameter("device", device) .executeUpdate(); query = em.createQuery("DELETE FROM Position x WHERE x.device = :device"); query.setParameter("device", device); query.executeUpdate(); query = em.createQuery("SELECT g FROM GeoFence g WHERE :device MEMBER OF g.devices"); query.setParameter("device", device); for (GeoFence geoFence : (List<GeoFence>) query.getResultList()) { geoFence.getDevices().remove(device); } em.flush(); query = em.createQuery("DELETE FROM Maintenance x WHERE x.device = :device"); query.setParameter("device", device); query.executeUpdate(); query = em.createQuery("DELETE FROM RegistrationMaintenance x WHERE x.device = :device"); query.setParameter("device", device); query.executeUpdate(); query = em.createQuery("DELETE FROM Sensor x WHERE x.device = :device"); query.setParameter("device", device); query.executeUpdate(); query = em.createQuery("SELECT x FROM Report x WHERE :device MEMBER OF x.devices"); query.setParameter("device", device); List<Report> reports = query.getResultList(); for (Report report : reports) { report.getDevices().remove(device); } query = em.createNativeQuery("Delete from devices where id = ?"); query.setParameter(1, device.getId()); query.executeUpdate(); }
From source file:org.apache.roller.weblogger.business.jpa.JPARefererManagerImpl.java
protected void clearDayHitsByWebsite(Weblog website) throws WebloggerException { Query query = strategy.getNamedUpdate("WeblogReferrer.clearDayHitsByWebsite"); query.setParameter(1, website);/*from ww w .j av a 2 s . c om*/ query.executeUpdate(); }
From source file:net.nan21.dnet.core.business.service.entity.AbstractEntityWriteService.java
/** * Execute a JPQL update statement./*www . j a va2 s . c o m*/ * * @param jpqlStatement * @param parameters * @return * @throws BusinessException */ public int update(String jpqlStatement, Map<String, Object> parameters) throws BusinessException { Query q = this.getEntityManager().createQuery(jpqlStatement); if (parameters != null) { for (Map.Entry<String, Object> p : parameters.entrySet()) { q.setParameter(p.getKey(), p.getValue()); } } return q.executeUpdate(); }
From source file:org.rhq.enterprise.server.event.EventManagerBean.java
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) @TransactionTimeout(6 * 60 * 60)// ww w . ja v a2s .c om public int purgeEventData(Date deleteUpToTime) throws SQLException { Query q = entityManager.createQuery("DELETE FROM Event e WHERE e.timestamp < :cutOff"); q.setParameter("cutOff", deleteUpToTime.getTime()); long startTime = System.currentTimeMillis(); int deleted = q.executeUpdate(); MeasurementMonitor.getMBean().incrementPurgeTime(System.currentTimeMillis() - startTime); MeasurementMonitor.getMBean().setPurgedEvents(deleted); return deleted; }
From source file:org.apache.roller.weblogger.business.jpa.JPARefererManagerImpl.java
/** * Clear referrer dayhits and remove referrers without excerpts. *//*from w w w . j ava 2 s . c om*/ public void clearReferrers(Weblog website) throws WebloggerException { clearDayHitsByWebsite(website); Query q = strategy.getNamedUpdate("WeblogReferrer.removeByNullOrEmptyExcerpt&Website"); q.setParameter(1, website); q.executeUpdate(); }
From source file:org.apache.syncope.core.persistence.jpa.dao.JPAGroupDAO.java
@Override public void clearADynMembers(final Group group) { Query delete = entityManager().createNativeQuery("DELETE FROM " + ADYNMEMB_TABLE + " WHERE group_id=?"); delete.setParameter(1, group.getKey()); delete.executeUpdate(); }
From source file:org.apache.syncope.core.persistence.jpa.dao.JPAGroupDAO.java
@Override public void clearUDynMembers(final Group group) { Query delete = entityManager().createNativeQuery("DELETE FROM " + UDYNMEMB_TABLE + " WHERE group_id=?"); delete.setParameter(1, group.getKey()); delete.executeUpdate(); }
From source file:org.rhq.enterprise.server.cloud.FailoverListManagerBean.java
public void deleteServerListsForAgent(Agent agent) { Query query1 = entityManager.createNamedQuery(FailoverListDetails.QUERY_DELETE_VIA_AGENT); Query query2 = entityManager.createNamedQuery(FailoverList.QUERY_DELETE_VIA_AGENT); query1.setParameter("agent", agent); query2.setParameter("agent", agent); query1.executeUpdate(); query2.executeUpdate();/* www.j a va 2s. co m*/ }