List of usage examples for javax.persistence Query executeUpdate
int executeUpdate();
From source file:com.expressui.sample.dao.UserDao.java
@Transactional @Override/*from w w w. j a v a 2 s . c o m*/ public void remove(User user) { Query query = getEntityManager() .createQuery("UPDATE Account a SET a.assignedTo = null WHERE a.assignedTo = :user"); query.setParameter("user", user); query.executeUpdate(); query = getEntityManager() .createQuery("UPDATE Contact c SET c.assignedTo = null WHERE c.assignedTo = :user"); query.setParameter("user", user); query.executeUpdate(); query = getEntityManager() .createQuery("UPDATE Opportunity o SET o.assignedTo = null WHERE o.assignedTo = :user"); query.setParameter("user", user); query.executeUpdate(); super.remove(user); }
From source file:org.oscarehr.common.dao.Hl7TextInfoDao.java
public void createUpdateLabelByLabNumber(String label, int lab_no) { String sql = "update Hl7TextInfo x set x.label=?1 where x.labNumber=?2"; Query query = entityManager.createQuery(sql); query.setParameter(1, label);//from w w w. j av a2s .c o m query.setParameter(2, lab_no); query.executeUpdate(); }
From source file:bq.jpa.demo.version.service.VersionService.java
/** * batch way need change version by ourselves *///www .j a va 2s.c o m @Transactional public void doUpdateVersionByQL() { Query update = em.createQuery( "UPDATE jpa_version_employee e SET e.name= CONCAT('new',e.name), e.version=e.version+1"); update.executeUpdate(); }
From source file:com.appdynamicspilot.persistence.CartPersistence.java
@Transactional public void deleteAllCartItems(Long userId) { EntityManager em = getEntityManager(); EntityTransaction txn = em.getTransaction(); txn.begin();/*from w ww. ja v a2 s . com*/ Query q = em.createQuery("DELETE FROM Cart c where c.user.id=:id"); q.setParameter("id", userId); q.executeUpdate(); txn.commit(); }
From source file:hr.diskobolos.persistence.impl.ADaoPersistenceImpl.java
@Override public void delete(List<T> entities) { if (!entities.isEmpty()) { Query query = entityManager.createNamedQuery(getType().getSimpleName() + ".deleteItems"); query.setParameter("forDeletion", entities); query.executeUpdate(); }//from ww w. ja v a 2s . co m }
From source file:com.ewcms.publication.PublishIntegratedTest.java
private void updateTemplateSourceStutas() { JpaTemplate template = createJpaTemplate(); template.execute(new JpaCallback<Object>() { @Override//from w w w . ja v a2 s. c o m public Object doInJpa(EntityManager em) throws PersistenceException { em.getTransaction().begin(); String hql = "Update TemplateSource o Set o.release= ?1 Where o.release = ?2"; Query query = em.createQuery(hql); query.setParameter(1, Boolean.FALSE); query.setParameter(2, Boolean.TRUE); query.executeUpdate(); em.getTransaction().commit(); return null; } }); }
From source file:org.kuali.mobility.emergencyinfo.dao.EmergencyInfoDaoImpl.java
public void deleteEmergencyInfoById(Long id) { Query query = entityManager.createQuery("delete from MaintEmergencyInfo ei where ei.emergencyInfoId = :id"); query.setParameter("id", id); query.executeUpdate(); }
From source file:org.apache.roller.weblogger.business.jpa.JPAAutoPingManagerImpl.java
public void removeAutoPing(PingTarget pingTarget, Weblog website) throws WebloggerException { Query q = strategy.getNamedUpdate("AutoPing.removeByPingTarget&Website"); q.setParameter(1, pingTarget);/*from w w w . j a v a 2 s . co m*/ q.setParameter(2, website); q.executeUpdate(); }
From source file:org.zkbase.dao.BasicDao.java
public int bulkUpdate(String queryString, Object... params) { Query query = entityManager.createQuery(queryString); setParameters(query, params);//w ww . j a v a2 s .co m return query.executeUpdate(); }
From source file:org.apache.roller.weblogger.business.jpa.JPAPingTargetManagerImpl.java
/** * Convenience method which removes any queued pings or auto pings that * reference the given ping target./*from w ww . ja v a 2 s .c om*/ */ private void removePingTargetContents(PingTarget ping) throws WebloggerException { // Remove the website's ping queue entries Query q = strategy.getNamedUpdate("PingQueueEntry.removeByPingTarget"); q.setParameter(1, ping); q.executeUpdate(); // Remove the website's auto ping configurations q = strategy.getNamedUpdate("AutoPing.removeByPingTarget"); q.setParameter(1, ping); q.executeUpdate(); }