List of usage examples for javax.persistence Query executeUpdate
int executeUpdate();
From source file:portal.api.impl.PortalJpaController.java
public void deleteAllMANOproviders() { EntityManager entityManager = entityManagerFactory.createEntityManager(); EntityTransaction entityTransaction = entityManager.getTransaction(); entityTransaction.begin();/*www. j a v a 2s .c o m*/ Query q = entityManager.createQuery("DELETE FROM MANOprovider"); q.executeUpdate(); entityManager.flush(); entityTransaction.commit(); }
From source file:de.micromata.genome.jpa.Emgr.java
/** * Execute the criteria update//from w w w . j a v a 2 s. c o m * * @param update the criteria to perform the update with * @return the updated entity */ private <E> int internalExecuteCriteriaUpdate(CriteriaUpdate<E> update) { Map<String, Object> args = new HashMap<String, Object>(); String hql = update.renderHql(args); Query query = createUntypedQuery(hql); for (Map.Entry<String, Object> me : args.entrySet()) { query.setParameter(me.getKey(), me.getValue()); } int ret = query.executeUpdate(); return ret; }
From source file:org.orcid.persistence.dao.impl.ProfileDaoImpl.java
@Override @Transactional//from www .j av a 2 s . c o m public void updateBiography(String orcid, String biography, Visibility visibility) { Query updateQuery = entityManager.createQuery( "update ProfileEntity set lastModified = now(), biography = :biography, biography_visibility = :visibility where orcid = :orcid"); updateQuery.setParameter("orcid", orcid); updateQuery.setParameter("biography", biography); updateQuery.setParameter("visibility", visibility == null ? null : StringUtils.upperCase(visibility.value())); updateQuery.executeUpdate(); }
From source file:org.orcid.persistence.dao.impl.ProfileDaoImpl.java
@Override @Transactional/* w w w .ja v a 2s .co m*/ public void updateSecurityQuestion(String orcid, Integer securityQuestionId, String encryptedSecurityAnswer) { Query updateQuery = entityManager.createQuery( "update ProfileEntity set lastModified = now(), securityQuestion.id = :securityQuestionId, encryptedSecurityAnswer = :encryptedSecurityAnswer where orcid = :orcid"); updateQuery.setParameter("orcid", orcid); updateQuery.setParameter("securityQuestionId", securityQuestionId); updateQuery.setParameter("encryptedSecurityAnswer", encryptedSecurityAnswer); updateQuery.executeUpdate(); }
From source file:org.eclipse.jubula.client.core.persistence.Persistor.java
/** * Update internal db statistics after mass changes in the db. * This is often needed to help the query optimizer doing the right things. *///from www. j av a 2 s .co m public void updateDbStatistics() { String cmd = dbConnectionInfo.getStatisticsCommand(); if (cmd != null) { EntityManager em = openSession(); try { Query q = em.createNativeQuery(cmd); EntityTransaction tx = getTransaction(em); q.executeUpdate(); commitTransaction(em, tx); } catch (Throwable t) { log.error("Updating DB statistics failed. This isn't critical, but will degrade performance.", t); //$NON-NLS-1$ } finally { dropSession(em); } } }
From source file:com.healthcit.cacure.dao.FormElementDao.java
/** * If the description list of a source element was changed, * this ensures that the description(s) of its associated LinkElements is up-to-date. *//*from www .j av a 2 s . c o m*/ public void updateAllFormElementsWithDescriptionChanged(FormElement formElement) { Iterator<Description> newDescriptionIterator = formElement.getDescriptionList().iterator(); while (newDescriptionIterator.hasNext()) { Description newDescription = newDescriptionIterator.next(); if (!newDescription.isNew()) { Query query = em.createNativeQuery( "update form_element set description = :desc from description d where form_element.link_id=:uuid and form_element.description = d.source_description_text and d.id = :id"); query.setParameter("desc", newDescription.getDescription()); query.setParameter("uuid", formElement.isLink() && !formElement.isExternalQuestion() ? ((LinkElement) formElement).getSourceId() : formElement.getUuid()); query.setParameter("id", newDescription.getId()); query.setFlushMode(FlushModeType.COMMIT); query.executeUpdate(); } } }
From source file:com.htm.db.spring.DataAccessRepositoryImpl.java
protected boolean executeUpdate(Query query) throws DatabaseException { try {/*from www. ja va 2 s . c o m*/ /* * executeUpdate returns the number of tuples that were deleted. If * there was at least one tuple deleted return true */ if (isTxActive()) { return query.executeUpdate() > 0 ? true : false; } else { throw new DatabaseException(NO_ACTIVE_TX_ERROR); } } catch (Exception e) { throw new DatabaseException(e); } }
From source file:org.orcid.persistence.dao.impl.ProfileDaoImpl.java
/** * enable or disable developer tools from a user * /* w w w .j a v a 2 s . c o m*/ * @param orcid * the orcid of the profile to be updated * @param enabled * the new value of the developer tools * @return true if the developer tools was successfully updated * */ @Override @Transactional public boolean updateDeveloperTools(String orcid, boolean enabled) { Query query = entityManager.createQuery( "update ProfileEntity set enableDeveloperTools=:enabled, lastModified=now() where orcid=:orcid"); if (enabled) query = entityManager.createQuery( "update ProfileEntity set enableDeveloperTools=:enabled, developerToolsEnabledDate=now(), lastModified=now() where orcid=:orcid"); query.setParameter("orcid", orcid); query.setParameter("enabled", enabled); return query.executeUpdate() > 0; }
From source file:org.orcid.persistence.dao.impl.ProfileDaoImpl.java
@Override @Transactional/*from www .j av a2 s.c o m*/ public void updateCountry(String orcid, Iso3166Country iso2Country, Visibility profileAddressVisibility) { Query updateQuery = entityManager.createQuery( "update ProfileEntity set lastModified = now(), iso2_country = :iso2Country, profile_address_visibility = :profileAddressVisibility where orcid = :orcid"); updateQuery.setParameter("orcid", orcid); updateQuery.setParameter("iso2Country", iso2Country != null ? iso2Country.value() : null); updateQuery.setParameter("profileAddressVisibility", StringUtils.upperCase(profileAddressVisibility.value())); updateQuery.executeUpdate(); }
From source file:com.tesora.dve.common.catalog.CatalogDAO.java
public void deleteAllServerRegistration() { Query q = em.get().createQuery("delete from ServerRegistration"); q.executeUpdate(); }