Package javax.persistence

Examples of javax.persistence.Query.executeUpdate()


  }
 
  public int executeNative (String query, Object... pars) {
    Query q = this.getStorage().createNativeQuery(query);
    for (int i=0; i<pars.length; i++) q.setParameter(i, pars[i]);
    return q.executeUpdate();
  }
 
  public List getNativeResults (String query) { return this.getNativeResults(query, new Object[0]); }
 
  public List getNativeResults (String query, Object... pars) {
View Full Code Here


    Query query = this.getStorage().createQuery(queryString);
    if (parameters != null) for (Object key : parameters.keySet()) {
      Object value = this.translateParameter( parameters.get(key) );
      if (queryString.contains(":" + key)) query.setParameter(key.toString(), value);
    }
    return query.executeUpdate();
  }
 
  public Object translateParameter (Object object) { return object; }
 
  public boolean exists (Map parameters, String queryString) {
View Full Code Here

     * Verifies if the container can make a bulk operation delete.
     */
    public void testDelete() {
        startup();
        Query query = entityManager.createQuery("DELETE FROM Customer c  WHERE  c.id > 2");
        query.executeUpdate();
        entityManager.flush();
        Query queryTest = entityManager.createQuery("SELECT c FROM Customer c");
        List lstCustomer = queryTest.getResultList();
        for (Object obj : lstCustomer) {
            Customer customer = (Customer) obj;
View Full Code Here

     * Verifies if the container can make a bulk operation update.
     */
    public void testUpdate() {
        startup();
        Query query = entityManager.createQuery("UPDATE Address a SET a.country = 'Brazil' WHERE a.id =1");
        query.executeUpdate();
        entityManager.flush();
        testVerifyUpdate();
      }

    /**
 
View Full Code Here

      tx.begin();
      Query query = session.createQuery(hql);
      query.setParameter("isTrash", isTrash);
      query.setParameter("privateMessageFolderId", privateMessageFolderId);
      query.setParameter("privateMessageIds", privateMessageIds);
      int updatedEntities = query.executeUpdate();
     
      //Refresh the Entities in the Cache as Hibernate will not do it!
      for (Long privateMessageId : privateMessageIds) {
        String hqlSel = "select c from PrivateMessages c " +
                "where c.privateMessageId = :privateMessageId ";
View Full Code Here

      EntityTransaction tx = session.getTransaction();
      tx.begin();
      Query query = session.createQuery(hql);
      query.setParameter("isRead", isRead);
      query.setParameter("privateMessageIds", privateMessageIds);
      int updatedEntities = query.executeUpdate();
     
      //Refresh the Entities in the Cache as Hibernate will not do it!
      for (Long privateMessageId : privateMessageIds) {
        String hqlSel = "select c from PrivateMessages c " +
                "where c.privateMessageId = :privateMessageId ";
View Full Code Here

      EntityTransaction tx = session.getTransaction();
      tx.begin();
      Query query = session.createQuery(hql);
      query.setParameter("privateMessageFolderId", privateMessageFolderId);
      query.setParameter("privateMessageIds", privateMessageIds);
      int updatedEntities = query.executeUpdate();
     
      //Refresh the Entities in the Cache as Hibernate will not do it!
      for (Long privateMessageId : privateMessageIds) {
        String hqlSel = "select c from PrivateMessages c " +
                "where c.privateMessageId = :privateMessageId ";
View Full Code Here

      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();
      Query query = session.createQuery(hql);
      query.setParameter("privateMessageIds", privateMessageIds);
      int updatedEntities = query.executeUpdate();
     
//      //Refresh the Entities in the Cache as Hibernate will not do it!
//      for (Long privateMessageId : privateMessageIds) {
//        String hqlSel = "select c from PrivateMessages c " +
//                "where c.privateMessageId = :privateMessageId ";
View Full Code Here

      EntityTransaction tx = session.getTransaction();
      tx.begin();
     
      Query query = session.createQuery(hql);
          query.setParameter("userContactId",userContactId);
          int rowCount = query.executeUpdate();
     
      tx.commit();
      PersistenceSessionUtil.closeSession(idf);
     
      return rowCount;     
View Full Code Here

      EntityTransaction tx = session.getTransaction();
      tx.begin();
     
      Query query = session.createQuery(hql);
          query.setParameter("ownerId",ownerId);
          int rowCount = query.executeUpdate();
     
      tx.commit();
      PersistenceSessionUtil.closeSession(idf);
     
      return rowCount;     
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.