List of usage examples for javax.persistence Query executeUpdate
int executeUpdate();
From source file:org.orcid.persistence.dao.impl.ProfileDaoImpl.java
@Override @Transactional//w w w . j a va 2 s .com public void updateIpAddress(String orcid, String ipAddress) { Query query = entityManager.createNativeQuery( "update profile set last_modified=now(), indexing_status='REINDEX', user_last_ip=:ipAddr where orcid=:orcid"); query.setParameter("orcid", orcid); query.setParameter("ipAddr", ipAddress); query.executeUpdate(); }
From source file:cn.hanbell.erp.ejb.CdrcusBean.java
public int updateSalesManInArmhad(String cusno, String origValue, String newValue) { Query query = getEntityManager().createNativeQuery( "update armhad set mancode = ?1 where mancode = ?2 and cusno = ?3 and (booamt - recamt > 0)"); query.setParameter(1, newValue);//from w w w .j av a 2 s .co m query.setParameter(2, origValue); query.setParameter(3, cusno); return query.executeUpdate(); }
From source file:org.orcid.persistence.dao.impl.ProfileDaoImpl.java
@Transactional private boolean changeLockedStatus(String orcid, boolean locked) { Query query = entityManager.createNativeQuery( "update profile set last_modified=now(), indexing_status='REINDEX', record_locked=:locked where orcid=:orcid"); query.setParameter("orcid", orcid); query.setParameter("locked", locked); return query.executeUpdate() > 0; }
From source file:org.orcid.persistence.dao.impl.ProfileDaoImpl.java
@Transactional private boolean changeReviewedStatus(String orcid, boolean reviewFlag) { Query query = entityManager.createNativeQuery( "update profile set last_modified=now(), indexing_status='REINDEX', reviewed=:reviewed where orcid=:orcid"); query.setParameter("orcid", orcid); query.setParameter("reviewed", reviewFlag); return query.executeUpdate() > 0; }
From source file:com.xidu.framework.common.dao.impl.BaseDaoImpl.java
/** * {@inheritDoc} overridden://ww w. ja v a2s . c om * * @Date : 2011-4-1 * @see com.xidu.framework.common.dao.IBaseDao#removeByQueryAndVaParam(java.lang.String, * java.lang.Object[]) **/ @Override public void removeByQueryAndVaParam(final String queryStr, final Object... params) { getJpaTemplate().execute(new JpaCallback<Integer>() { @Override public Integer doInJpa(EntityManager em) throws PersistenceException { // TODO Auto-generated method stub Query removeQuery = em.createQuery(queryStr); prepareQueryParam(removeQuery, params); return removeQuery.executeUpdate(); } }); }
From source file:com.xidu.framework.common.dao.impl.BaseDaoImpl.java
/** * {@inheritDoc} overridden://from w ww . j a va 2 s . c o m * * @Date : 2011-4-1 * @see com.xidu.framework.common.dao.IBaseDao#updateByQUeryAndVaParam(java.lang.String, * java.lang.Object[]) **/ @Override public void updateByQUeryAndVaParam(final String queryStr, final Object... params) { // TODO Auto-generated method stub getJpaTemplate().execute(new JpaCallback<Integer>() { @Override public Integer doInJpa(EntityManager em) throws PersistenceException { // TODO Auto-generated method stub Query updateQuery = em.createQuery(queryStr); prepareQueryParam(updateQuery, params); return updateQuery.executeUpdate(); } }); }
From source file:com.xidu.framework.common.dao.impl.BaseDaoImpl.java
/** * {@inheritDoc} overridden://from www . j a v a 2s .com * * @Date : 2011-4-1 * @see com.xidu.framework.common.dao.IBaseDao#removeByQueryAndMap(java.lang.String, * java.util.Map) **/ @Override public void removeByQueryAndMap(final String queryStr, final Map<String, ?> paraMap) { getJpaTemplate().execute(new JpaCallback<Integer>() { @Override public Integer doInJpa(EntityManager em) throws PersistenceException { // TODO Auto-generated method stub Query removeQuery = em.createQuery(queryStr); prepareQueryParam(removeQuery, paraMap); return removeQuery.executeUpdate(); } }); }
From source file:com.xidu.framework.common.dao.impl.BaseDaoImpl.java
/** * {@inheritDoc} overridden://from www. j a v a 2s. c o m * * @Date : 2011-4-1 * @see com.xidu.framework.common.dao.IBaseDao#updateByQueryAndMap(java.lang.String, * java.util.Map) **/ @Override public void updateByQueryAndMap(final String queryStr, final Map<String, ?> paraMap) { // TODO Auto-generated method stub getJpaTemplate().execute(new JpaCallback<Integer>() { @Override public Integer doInJpa(EntityManager em) throws PersistenceException { // TODO Auto-generated method stub Query updateQuery = em.createQuery(queryStr); prepareQueryParam(updateQuery, paraMap); return updateQuery.executeUpdate(); } }); }
From source file:org.orcid.persistence.dao.impl.ProfileDaoImpl.java
public void updateEncryptedPassword(String orcid, String encryptedPassword) { Query updateQuery = entityManager.createQuery( "update ProfileEntity set lastModified = now(), encryptedPassword = :encryptedPassword where orcid = :orcid"); updateQuery.setParameter("orcid", orcid); updateQuery.setParameter("encryptedPassword", encryptedPassword); updateQuery.executeUpdate(); }
From source file:com.jada.admin.site.SiteLoader.java
public void remove() throws Exception { EntityManager em = JpaConnection.getInstance().getCurrentEntityManager(); String sql = null;/*w ww . jav a 2 s . c om*/ Query query = null; Iterator<?> iterator = null; sql = "delete from CreditCard where siteId = :siteId"; query = em.createQuery(sql); query.setParameter("siteId", site.getSiteId()); query.executeUpdate(); sql = "from Report report where report.site.siteId = :siteId"; query = em.createQuery(sql); query.setParameter("siteId", site.getSiteId()); iterator = query.getResultList().iterator(); while (iterator.hasNext()) { Report report = (Report) iterator.next(); em.remove(report); } sql = "from IeProfileHeader ieProfileHeader where ieProfileHeader.site.siteId = :siteId"; query = em.createQuery(sql); query.setParameter("siteId", site.getSiteId()); iterator = query.getResultList().iterator(); while (iterator.hasNext()) { IeProfileHeader ieProfileHeader = (IeProfileHeader) iterator.next(); for (IeProfileDetail ieProfileDetail : ieProfileHeader.getIeProfileDetails()) { em.remove(ieProfileDetail); } em.remove(ieProfileHeader); } sql = "from Menu menu where menu.siteDomain in (select siteDomain from SiteDomain siteDomain where siteDomain.site.siteId = :siteId)"; query = em.createQuery(sql); query.setParameter("siteId", site.getSiteId()); iterator = query.getResultList().iterator(); while (iterator.hasNext()) { Menu menu = (Menu) iterator.next(); menu.setMenuLanguage(null); for (MenuLanguage menuLanguage : menu.getMenuLanguages()) { em.remove(menuLanguage); } em.remove(menu); } sql = "from Category category where category.site.siteId = :siteId)"; query = em.createQuery(sql); query.setParameter("siteId", site.getSiteId()); iterator = query.getResultList().iterator(); while (iterator.hasNext()) { Category category = (Category) iterator.next(); category.setCategoryLanguage(null); for (CategoryLanguage categoryLanguage : category.getCategoryLanguages()) { em.remove(categoryLanguage); } em.remove(category); } sql = "delete from ProductClass productClass where productClass.site.siteId = :siteId)"; query = em.createQuery(sql); query.setParameter("siteId", site.getSiteId()); query.executeUpdate(); sql = "delete from CustomerClass customerClass where customerClass.site.siteId = :siteId)"; query = em.createQuery(sql); query.setParameter("siteId", site.getSiteId()); query.executeUpdate(); sql = "from ShippingRate shippingRate " + "where shippingRate in ( " + "select shippingRate " + "from ShippingMethodRegionType shippingMethodRegionType " + "where shippingMethodRegionType.shippingMethod.site.siteId = :siteId " + ")"; query = em.createQuery(sql); query.setParameter("siteId", site.getSiteId()); iterator = query.getResultList().iterator(); while (iterator.hasNext()) { ShippingRate shippingRate = (ShippingRate) iterator.next(); em.remove(shippingRate); } sql = "from ShippingMethod where siteId = :siteId"; query = em.createQuery(sql); query.setParameter("siteId", site.getSiteId()); iterator = query.getResultList().iterator(); while (iterator.hasNext()) { ShippingMethod shippingMethod = (ShippingMethod) iterator.next(); em.remove(shippingMethod.getShippingMethodLanguage()); em.remove(shippingMethod); } sql = "from ShippingRegion where siteId = :siteId"; query = em.createQuery(sql); query.setParameter("siteId", site.getSiteId()); iterator = query.getResultList().iterator(); while (iterator.hasNext()) { ShippingRegion shippingRegion = (ShippingRegion) iterator.next(); em.remove(shippingRegion); } sql = "from ShippingType where siteId = :siteId"; query = em.createQuery(sql); query.setParameter("siteId", site.getSiteId()); iterator = query.getResultList().iterator(); while (iterator.hasNext()) { ShippingType shippingType = (ShippingType) iterator.next(); em.remove(shippingType); } sql = "from State where stateId in (select stateId from State state where state.country.site.siteId = :siteId)"; query = em.createQuery(sql); query.setParameter("siteId", site.getSiteId()); iterator = query.getResultList().iterator(); while (iterator.hasNext()) { State state = (State) iterator.next(); state.setCountry(null); em.remove(state); } sql = "from Country where siteId = :siteId"; query = em.createQuery(sql); query.setParameter("siteId", site.getSiteId()); iterator = query.getResultList().iterator(); while (iterator.hasNext()) { Country country = (Country) iterator.next(); em.remove(country); } site.setSiteCurrencyClassDefault(null); site.setSiteProfileClassDefault(null); for (SiteDomain siteDomain : site.getSiteDomains()) { siteDomain.setSiteProfileDefault(null); siteDomain.setSiteCurrencyDefault(null); siteDomain.setBaseCurrency(null); siteDomain.setSiteDomainLanguage(null); HomePage homePage = siteDomain.getHomePage(); for (HomePageDetail homePageDetail : homePage.getHomePageDetails()) { em.remove(homePageDetail); } for (HomePageLanguage homePageLanguage : homePage.getHomePageLanguages()) { em.remove(homePageLanguage); } em.remove(homePage); siteDomain.setHomePage(null); Template template = siteDomain.getTemplate(); em.remove(template); siteDomain.setTemplate(null); } sql = "from SiteProfile siteProfile where siteProfile.siteDomain.site.siteId = :siteId"; query = em.createQuery(sql); query.setParameter("siteId", site.getSiteId()); iterator = query.getResultList().iterator(); while (iterator.hasNext()) { SiteProfile siteProfile = (SiteProfile) iterator.next(); em.remove(siteProfile); } sql = "from SiteCurrency siteCurrency where siteCurrency.siteDomain.site.siteId = :siteId"; query = em.createQuery(sql); query.setParameter("siteId", site.getSiteId()); iterator = query.getResultList().iterator(); while (iterator.hasNext()) { SiteCurrency siteCurrency = (SiteCurrency) iterator.next(); em.remove(siteCurrency); } sql = "from SiteProfileClass siteProfileClass where siteProfileClass.site.siteId = :siteId"; query = em.createQuery(sql); query.setParameter("siteId", site.getSiteId()); iterator = query.getResultList().iterator(); while (iterator.hasNext()) { SiteProfileClass siteProfileClass = (SiteProfileClass) iterator.next(); em.remove(siteProfileClass); } sql = "from SiteCurrencyClass siteCurrencyClass where siteCurrencyClass.site.siteId = :siteId"; query = em.createQuery(sql); query.setParameter("siteId", site.getSiteId()); iterator = query.getResultList().iterator(); while (iterator.hasNext()) { SiteCurrencyClass siteCurrencyClass = (SiteCurrencyClass) iterator.next(); siteCurrencyClass.setCurrency(null); em.remove(siteCurrencyClass); } sql = "from Currency currency where currency.site.siteId = :siteId"; query = em.createQuery(sql); query.setParameter("siteId", site.getSiteId()); iterator = query.getResultList().iterator(); while (iterator.hasNext()) { Currency currency = (Currency) iterator.next(); em.remove(currency); } sql = "from CustomAttribute customAttribute where customAttribute.site.siteId = :siteId"; query = em.createQuery(sql); query.setParameter("siteId", site.getSiteId()); iterator = query.getResultList().iterator(); while (iterator.hasNext()) { CustomAttribute customAttribute = (CustomAttribute) iterator.next(); em.remove(customAttribute); CustomAttributeLanguage customAttributeLanguage = customAttribute.getCustomAttributeLanguage(); customAttributeLanguage.setCustomAttribute(null); em.remove(customAttributeLanguage); } sql = "from SiteDomain siteDomain where siteDomain.site.siteId = :siteId"; query = em.createQuery(sql); query.setParameter("siteId", site.getSiteId()); iterator = query.getResultList().iterator(); while (iterator.hasNext()) { SiteDomain siteDomain = (SiteDomain) iterator.next(); for (SiteDomainLanguage siteDomainLanguage : siteDomain.getSiteDomainLanguages()) { em.remove(siteDomainLanguage); } em.remove(siteDomain); } }