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:com.clustercontrol.maintenance.util.QueryUtil.java

public static int deleteCollectDataByDateTimeAndMonitorId(Long dateTime, int timeout, String monitorId) {
    HinemosEntityManager em = new JpaTransactionManager().getEntityManager();
    Query query = em.createNamedQuery("CollectData.deleteByDateTimeAndMonitorId")
            .setParameter("dateTime", dateTime).setParameter("monitorId", monitorId);
    if (timeout > 0) {
        query = query.setHint(JpaPersistenceConfig.JPA_PARAM_QUERY_TIMEOUT, timeout * 1000);
    }//from   w  ww.j a v a  2 s.  c  o m
    return query.executeUpdate();
}

From source file:com.clustercontrol.maintenance.util.QueryUtil.java

public static int deleteSummaryHourByDateTimeAndMonitorId(Long dateTime, int timeout, String monitorId) {
    HinemosEntityManager em = new JpaTransactionManager().getEntityManager();
    Query query = em.createNamedQuery("SummaryHour.deleteByDateTimeAndMonitorId")
            .setParameter("dateTime", dateTime).setParameter("monitorId", monitorId);
    if (timeout > 0) {
        query = query.setHint(JpaPersistenceConfig.JPA_PARAM_QUERY_TIMEOUT, timeout * 1000);
    }/*from   www  .ja  va 2  s  .  c  om*/
    return query.executeUpdate();
}

From source file:com.clustercontrol.maintenance.util.QueryUtil.java

public static int deleteSummaryMonthByDateTimeAndMonitorId(Long dateTime, int timeout, String monitorId) {
    HinemosEntityManager em = new JpaTransactionManager().getEntityManager();
    Query query = em.createNamedQuery("SummaryMonth.deleteByDateTimeAndMonitorId")
            .setParameter("dateTime", dateTime).setParameter("monitorId", monitorId);
    if (timeout > 0) {
        query = query.setHint(JpaPersistenceConfig.JPA_PARAM_QUERY_TIMEOUT, timeout * 1000);
    }//from  ww  w .j  a v a 2 s . c  o m
    return query.executeUpdate();
}

From source file:com.clustercontrol.maintenance.util.QueryUtil.java

public static int deleteCollectStringDataByDateTimeAndMonitorId(Long dateTime, int timeout, String monitorId) {
    HinemosEntityManager em = new JpaTransactionManager().getEntityManager();
    Query query = em.createNamedQuery("CollectStringData.deleteByDateTimeAndMonitorId")
            .setParameter("dateTime", dateTime).setParameter("monitorId", monitorId);
    if (timeout > 0) {
        query = query.setHint(JpaPersistenceConfig.JPA_PARAM_QUERY_TIMEOUT, timeout * 1000);
    }//from w  w w .  j  a  v  a  2  s. co m
    return query.executeUpdate();
}

From source file:com.clustercontrol.maintenance.util.QueryUtil.java

public static int deleteEventLogByGenerationDateAndOwnerRoleId(Long generationDate, int timeout,
        String roleId) {//from  w  w w.  j  a  v a  2s  . co  m
    HinemosEntityManager em = new JpaTransactionManager().getEntityManager();

    Query query = em.createNamedQuery("EventLogEntity.deleteByGenerationDateAndOwnerRoleId")
            .setParameter("generationDate", generationDate).setParameter("ownerRoleId", roleId);
    if (timeout > 0) {
        query = query.setHint(JpaPersistenceConfig.JPA_PARAM_QUERY_TIMEOUT, timeout * 1000);
    }
    return query.executeUpdate();
}

From source file:com.clustercontrol.maintenance.util.QueryUtil.java

public static int deleteEventLogByGenerationDateConfigFlgAndOwnerRoleId(Long generationDate, int timeout,
        String roleId) {//from  ww  w .  j  a  va 2  s.  com
    HinemosEntityManager em = new JpaTransactionManager().getEntityManager();
    Query query = em.createNamedQuery("EventLogEntity.deleteByGenerationDateConfigFlgAndOwnerRoleId")
            .setParameter("generationDate", generationDate).setParameter("ownerRoleId", roleId);
    if (timeout > 0) {
        query = query.setHint(JpaPersistenceConfig.JPA_PARAM_QUERY_TIMEOUT, timeout * 1000);
    }
    return query.executeUpdate();
}

From source file:au.org.ands.vocabs.toolkit.db.AccessPointUtils.java

/** Delete all access points of a certain type for a version.
 * @param version The version.//w w  w.  j a v a2 s.  c om
 * @param type The type of access point to look for.
 */
public static void deleteAccessPointsForVersionAndType(final Version version, final String type) {
    EntityManager em = DBContext.getEntityManager();
    em.getTransaction().begin();
    Query q = em.createNamedQuery(AccessPoint.DELETE_ACCESSPOINTS_FOR_VERSION_AND_TYPE)
            .setParameter(AccessPoint.DELETE_ACCESSPOINTS_FOR_VERSION_AND_TYPE_VERSIONID, version.getId())
            .setParameter(AccessPoint.DELETE_ACCESSPOINTS_FOR_VERSION_AND_TYPE_TYPE, type);
    q.executeUpdate();
    em.getTransaction().commit();
    em.close();
}

From source file:org.opentides.persistence.evolve.Evolver.java

@Transactional
public int executeJpqlUpdate(String query) {
    Query q = em.createQuery(query);
    return q.executeUpdate();
}

From source file:org.opentides.persistence.evolve.Evolver.java

@Transactional
public int executeSqlUpdate(String query) {
    Query q = em.createNativeQuery(query);
    return q.executeUpdate();
}

From source file:com.emc.plants.service.impl.ResetDBBean.java

public void deleteAll() {
    try {//from   ww w.  j ava 2s  .co  m
        Query q = em.createNamedQuery("removeAllOrders");
        q.executeUpdate();
        q = em.createNamedQuery("removeAllInventory");
        q.executeUpdate();
        q = em.createNamedQuery("removeAllIdGenerator");
        q.executeUpdate();
        q = em.createNamedQuery("removeAllCustomers");
        q.executeUpdate();
        q = em.createNamedQuery("removeAllOrderItem");
        q.executeUpdate();
        q = em.createNamedQuery("removeAllBackOrder");
        q.executeUpdate();
        q = em.createNamedQuery("removeAllSupplier");
        q.executeUpdate();
        em.flush();
    } catch (Exception e) {
        Util.debug("ResetDB(deleteAll) -- Error deleting data from the database: " + e);
        e.printStackTrace();
    }

}