List of usage examples for javax.persistence Query executeUpdate
int executeUpdate();
From source file:org.rhq.enterprise.server.measurement.MeasurementBaselineManagerBean.java
@SuppressWarnings("unused") @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) //@TransactionTimeout( 60 * 60 ) private int _calculateAutoBaselinesDELETE_HQL(long startTime, long endTime) throws Exception { Query query = entityManager.createNamedQuery(MeasurementBaseline.QUERY_DELETE_EXISTING_AUTOBASELINES); query.setParameter("startTime", startTime); query.setParameter("endTime", endTime); int rowsModified = query.executeUpdate(); return rowsModified; }
From source file:org.tolven.analysis.bean.SnapshotBean.java
/** * This function deletes all cohort placeholders, * on any change in the cohort properties. *//*from ww w. j a v a2s.c o m*/ @Override public void deleteCohortPlaceholder(Account account, String cohortType) { Query query = em.createQuery("delete PlaceholderID pi WHERE " + "pi.account.id = :account and pi.extension LIKE '" + cohortType + "%'"); query.setParameter("account", account.getId()); query.executeUpdate(); }
From source file:org.nuxeo.ecm.activity.ActivityStreamServiceImpl.java
protected void removeActivities(EntityManager em, Collection<Activity> activities) { try {//w w w . j a va 2 s. co m localEntityManager.set(em); ActivitiesList l = new ActivitiesListImpl(activities); for (ActivityStreamFilter filter : activityStreamFilters.values()) { filter.handleRemovedActivities(this, l); } Query query = em.createQuery("delete from Activity activity where activity.id in (:ids)"); query.setParameter("ids", l.toActivityIds()); query.executeUpdate(); } finally { localEntityManager.remove(); } }
From source file:org.sofun.core.member.MemberServiceImpl.java
@Override public Member deleteMember(String email) { Member member = getMember(email); if (member != null) { String queryStr = "delete from " + MemberImpl.class.getSimpleName() + " m where m.email=:email"; Query query = createQuery(queryStr); query.setParameter("email", email); query.setMaxResults(1);//from ww w . j ava 2 s . c o m query.executeUpdate(); } return member; }
From source file:org.easyj.orm.jpa.JPAEntityDao.java
private int executeUpdate(String query, Map<String, Object> params) { Query q; int result = -1; try {//from w w w. j a va 2s. c o m if (query.toLowerCase().startsWith("update ") || query.toLowerCase().startsWith("insert into") || query.toLowerCase().startsWith("delete from ")) { q = em.createNativeQuery(query); } else { q = em.createNamedQuery(query); } if (setParameters(q, params)) { result = q.executeUpdate(); } } finally { closeEm(); } return result; }
From source file:net.firejack.platform.core.store.BaseStore.java
public int update(final String queryName, final Object... params) { return (Integer) getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Query query = session.getNamedQuery(queryName); setQueryParams(query, params); return query.executeUpdate(); }/* w w w. j av a2 s . c o m*/ }); }
From source file:org.tolven.analysis.bean.SnapshotBean.java
/** * This function deletes all previous entries in the snapshot lists, * while taking a new snapshot./*w w w.j av a 2 s . c o m*/ */ @Override public void deleteAnalysisList(Account account, String snapshotType) { Query query = em.createQuery("update MenuData md set md.deleted=TRUE WHERE " + "md.account.id = :account and md.path LIKE '%" + snapshotType + "%' "); query.setParameter("account", account.getId()); query.executeUpdate(); }
From source file:org.openmeetings.app.data.user.dao.PrivateMessagesDaoImpl.java
public Integer moveMailsToFolder(List<Long> privateMessageIds, Long privateMessageFolderId) { try {// ww w . j a va 2 s .c om String hql = "UPDATE PrivateMessages c " + "SET c.privateMessageFolderId = :privateMessageFolderId, c.isTrash = false " + "where c.privateMessageId IN (:privateMessageIds) "; Query query = em.createQuery(hql); query.setParameter("privateMessageFolderId", privateMessageFolderId); query.setParameter("privateMessageIds", privateMessageIds); int updatedEntities = query.executeUpdate(); //Refresh the Entities in the Cache as Hibernate will not do it! //FIXME weird code for (Long privateMessageId : privateMessageIds) { String hqlSel = "select c from PrivateMessages c " + "where c.privateMessageId = :privateMessageId "; TypedQuery<PrivateMessages> querySel = em.createQuery(hqlSel, PrivateMessages.class); querySel.setParameter("privateMessageId", privateMessageId); try { querySel.getSingleResult(); } catch (NoResultException ex) { } } return updatedEntities; } catch (Exception e) { log.error("[updatePrivateMessagesReadStatus]", e); } return -1; }
From source file:gr.upatras.ece.nam.baker.impl.BakerJpaController.java
public void deleteAllUsers() { EntityManager entityManager = entityManagerFactory.createEntityManager(); EntityTransaction entityTransaction = entityManager.getTransaction(); entityTransaction.begin();/*from w w w. j av a2 s . co m*/ Query q = entityManager.createQuery("DELETE FROM BakerUser "); q.executeUpdate(); entityManager.flush(); entityTransaction.commit(); }
From source file:gr.upatras.ece.nam.baker.impl.BakerJpaController.java
public void deleteAllInstalledBuns() { EntityManager entityManager = entityManagerFactory.createEntityManager(); EntityTransaction entityTransaction = entityManager.getTransaction(); entityTransaction.begin();/*ww w .java2 s. c o m*/ Query q = entityManager.createQuery("DELETE FROM InstalledBun "); q.executeUpdate(); entityManager.flush(); entityTransaction.commit(); }