Example usage for javax.persistence Query executeUpdate

List of usage examples for javax.persistence Query executeUpdate

Introduction

In this page you can find the example usage for javax.persistence Query executeUpdate.

Prototype

int executeUpdate();

Source Link

Document

Execute an update or delete statement.

Usage

From source file:be.fedict.trust.service.dao.bean.CertificateAuthorityDAOBean.java

public int removeOldRevokedCertificates(BigInteger crlNumber, String issuerName) {
    LOG.debug("deleting revoked certificates (issuer=" + issuerName + " older than crl=" + crlNumber + ")");
    Query query = this.entityManager
            .createNamedQuery(RevokedCertificateEntity.DELETE_WHERE_ISSUER_OLDER_CRL_NUMBER);
    query.setParameter("issuer", issuerName);
    query.setParameter("crlNumber", crlNumber);
    int deleteResult = query.executeUpdate();
    LOG.debug("delete result: " + deleteResult);
    this.entityManager.flush();
    return deleteResult;
}

From source file:org.rhq.enterprise.server.alert.AlertNotificationManagerBean.java

public int purgeOrphanedAlertNotifications() {
    Query purgeQuery = entityManager.createNamedQuery(AlertNotification.QUERY_DELETE_ORPHANED);
    return purgeQuery.executeUpdate();
}

From source file:org.orcid.persistence.dao.impl.OrgDisambiguatedDaoImpl.java

@Override
@Transactional// www  .j  a v  a2  s  . co  m
public void updatePopularity(Long orgDisambiguatedId, Integer popularity) {
    Query query = entityManager.createQuery(
            "update OrgDisambiguatedEntity set indexingStatus = 'PENDING', popularity = :popularity where id = :orgDisambiguatedId");
    query.setParameter("orgDisambiguatedId", orgDisambiguatedId);
    query.setParameter("popularity", popularity);
    query.executeUpdate();
}

From source file:com.exp.tracker.services.impl.JpaUserService.java

@Transactional
public void removeAuthById(Long id, RequestContext ctx) {
    if (logger.isDebugEnabled()) {
        logger.debug("About to remove auth record with id " + id);
    }//  www .  j a  v a2  s .  co  m
    Query queryRemoveAuthority = em.createNamedQuery("removeAuthority");
    queryRemoveAuthority.setParameter("id", id);
    queryRemoveAuthority.executeUpdate();
    // Add message to be displayed on UI
    ctx.getMessageContext()
            .addMessage(new MessageBuilder().info().defaultText("The role was deleted successfuly.").build());
}

From source file:org.syncope.core.persistence.dao.impl.ResourceDAOImpl.java

@Override
public void deleteMappings(final String intAttrName, final IntMappingType intMappingType) {

    if (intMappingType == IntMappingType.SyncopeUserId || intMappingType == IntMappingType.Password
            || intMappingType == IntMappingType.Username) {

        return;//from w ww . j a  v  a 2 s  .c  o m
    }

    Query query = entityManager.createQuery("DELETE FROM " + SchemaMapping.class.getSimpleName()
            + " m WHERE m.intAttrName=:intAttrName " + "AND m.intMappingType=:intMappingType");
    query.setParameter("intAttrName", intAttrName);
    query.setParameter("intMappingType", intMappingType);

    int items = query.executeUpdate();
    LOG.debug("Removed {} schema mappings", items);

    // Make empty SchemaMapping query cache
    entityManager.getEntityManagerFactory().getCache().evict(SchemaMapping.class);
}

From source file:org.syncope.core.util.ImportExport.java

@Override
public void startElement(final String uri, final String localName, final String qName, final Attributes atts)
        throws SAXException {

    // skip root element
    if (ROOT_ELEMENT.equals(qName)) {
        return;/*ww w .  j  a  va 2s .  c o  m*/
    }

    StringBuilder queryString = new StringBuilder("INSERT INTO ").append(qName).append('(');

    StringBuilder values = new StringBuilder();

    for (int i = 0; i < atts.getLength(); i++) {
        queryString.append(atts.getQName(i));
        values.append('?');
        if (i < atts.getLength() - 1) {
            queryString.append(',');
            values.append(',');
        }
    }
    queryString.append(") VALUES (").append(values).append(')');

    Query query = entityManager.createNativeQuery(queryString.toString());
    setParameters(qName, atts, query);
    query.executeUpdate();
}

From source file:org.orcid.persistence.dao.impl.OrcidOauth2TokenDetailDaoImpl.java

@Override
public void removeByUserOrcidAndClientOrcid(String userOrcid, String clientOrcid) {
    Query query = entityManager.createQuery(
            "delete from OrcidOauth2TokenDetail where profile.id = :userOrcid and clientDetailsId = :clientOrcid");
    query.setParameter("userOrcid", userOrcid);
    query.setParameter("clientOrcid", clientOrcid);
    int i = query.executeUpdate();
    if (i == 0) {
        LOGGER.info(/* w  w w.  j a va 2 s .  co m*/
                "Attempted to tokens for user {0} and client application {1} but none were present in the database",
                userOrcid, clientOrcid);
    }
}

From source file:org.medici.bia.dao.volume.VolumeDAOJpaImpl.java

@Override
public Integer updateNewDigitizedVolume(List<Integer> summaryIds) throws PersistenceException {
    String hql = "UPDATE Volume set digitized=true where summaryId in (:summaryIds)";

    Query query = getEntityManager().createQuery(hql);

    query.setParameter("summaryIds", summaryIds);

    return query.executeUpdate();
}

From source file:org.apache.falcon.jdbc.MonitoringJdbcStateStore.java

public void updateSLAAlertInstance(String feedName, String clusterName, Date nominalTime) {
    EntityManager entityManager = getEntityManager();
    beginTransaction(entityManager);//from   w w w  . ja v a 2  s  . c  o  m
    Query q = entityManager.createNamedQuery(PersistenceConstants.UPDATE_SLA_HIGH);
    q.setParameter("feedName", feedName);
    q.setParameter("clusterName", clusterName);
    q.setParameter("nominalTime", nominalTime);
    try {
        q.executeUpdate();
    } finally {
        commitAndCloseTransaction(entityManager);
    }
}

From source file:org.apache.falcon.jdbc.MonitoringJdbcStateStore.java

public void deleteFeedAlertInstance(String feedName, String clusterName, Date nominalTime) {
    EntityManager entityManager = getEntityManager();
    beginTransaction(entityManager);//from   w w  w  .  ja v  a2 s. com
    Query q = entityManager.createNamedQuery(PersistenceConstants.DELETE_FEED_ALERT_INSTANCE);
    q.setParameter("feedName", feedName);
    q.setParameter("clusterName", clusterName);
    q.setParameter("nominalTime", nominalTime);
    try {
        q.executeUpdate();
    } finally {
        commitAndCloseTransaction(entityManager);
    }
}