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:eu.europa.ec.fisheries.uvms.rules.dao.RuleStatusDao.java

public void deleteRuleStatus() throws ServiceException {
    Query query = getEntityManager().createNamedQuery(RuleStatus.DELETE_ALL);
    query.executeUpdate();
}

From source file:com.sshdemo.common.security.web.authentication.rememberme.dao.RememberMeTokenDAO.java

public void removeUserTokens(final String username) {
    String hql = "Delete From RememberMeToken o Where o.username=:username ";

    Query query = this.getEntityManager().createQuery(hql);
    query.setParameter("username", username);

    query.executeUpdate();
}

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

public void clearAudits() {
    Query query = this.entityManager.createNamedQuery(AuditEntity.REMOVE_ALL);
    int removed = query.executeUpdate();
    LOG.debug("# removed audit records: " + removed);
}

From source file:com.mir00r.jdbc_dao.HibernateDao.java

public int getEmployee() {
    String hql = "select count(*) from Employee";
    Query query = (Query) getSf().openSession().createQuery(hql);

    // return ((Long) query.uniqueResult()).intValue();
    return query.executeUpdate();
}

From source file:net.chrissearle.flickrvote.dao.JpaPhotographyDao.java

/**
 * Method clearVotes removes all votes from the entire system.
 *///from w ww. j  a  v  a2s .c  o  m
public void clearVotes() {
    Query query = entityManager.createQuery("DELETE FROM Vote v");
    query.executeUpdate();
}

From source file:bc8.movies.dao.UserDaoImpl.java

public void rateMovie(User user, Movie movie, int rating) {
    String id = String.format("%05d%05d", user.getId(), movie.getId());
    StringBuilder sb = new StringBuilder();
    sb.append("insert into ").append(Constants.DB_TABLE_USER_MOVIE)
            .append(" (id, userId, movieId, rating) values (").append(id).append(", ").append(user.getId())
            .append(", ").append(movie.getId()).append(", ").append(rating)
            .append(") on duplicate key update rating=values(rating)");

    Query query = em.createNativeQuery(sb.toString());

    query.executeUpdate();
}

From source file:bc8.movies.dao.UserDaoImpl.java

public void favoriteMovie(User user, Movie movie, boolean favorited) {
    int favorite = (favorited) ? 1 : 0;

    String id = String.format("%05d%05d", user.getId(), movie.getId());
    StringBuilder sb = new StringBuilder();
    sb.append("insert into ").append(Constants.DB_TABLE_USER_MOVIE)
            .append(" (id, userId, movieId, favorite) values ('").append(id).append("', ").append(user.getId())
            .append(", ").append(movie.getId()).append(", ").append(favorite)
            .append(") on duplicate key update favorite=values(favorite);");

    Query query = em.createNativeQuery(sb.toString());

    query.executeUpdate();
}

From source file:org.apache.ode.dao.jpa.hibernate.JpaOperatorImpl.java

public <T> void batchUpdateByIds(Iterator<T> ids, Query query, String parameterName) {
    while (ids.hasNext()) {
        query.setParameter(parameterName, ids.next());
        query.executeUpdate();
    }//  www .j av a 2  s  .c o m
}

From source file:org.reusables.access.AbstractEntityManagerRepository.java

@Override
public int deleteById(final Serializable id, final String idPropertyName) {
    final String qlString = String.format("DELETE %s WHERE %s = :id", this.entityClass.getName(),
            idPropertyName);/*  w w w.j ava2  s  .  c o  m*/
    final Query query = getEm().createQuery(qlString);
    query.setParameter("id", id);
    return query.executeUpdate();
}

From source file:com.sshdemo.common.security.manage.dao.UserDAO.java

@Override
public void updatePassword(final String username, final String password) {
    String hql = "Update User o Set o.password=:password Where username=:username";

    Query query = this.getEntityManager().createQuery(hql);
    query.setParameter("username", username);
    query.setParameter("password", password);

    query.executeUpdate();
}