Package org.hibernate

Examples of org.hibernate.Query.executeUpdate()


      Query q = ssn.createQuery(hql.toString());
      q.setInteger(0, incCount);
      for(int i=1;i<=music_ids.length;i++){
        q.setParameter(i, new Integer(music_ids[i-1]));
      }
      int er = q.executeUpdate();
      commit();
      return er;
    }catch(HibernateException e){
      rollback();
      throw e;
View Full Code Here


        q2.setParameter(0, null);
        for(;i<ids.length;i++){
          q2.setInteger(i+1, ids[i]);
        }
        q2.setInteger(i+1, ids[0]);
        q2.executeUpdate();
        //ɾ������
        for(i=0;i<musics.size();i++){
          MusicBean mbean = (MusicBean)musics.get(i);
          if(mbean.getMusicBox()!=null)
            mbean.getMusicBox().incMusicCount(-1);
View Full Code Here

          id = Integer.parseInt(s_id);
        }catch(Exception e){}
        q.setInteger(i+1, id);
      }
      q.setInteger(i+1, -1);
      int er = q.executeUpdate();
      commit();
      return er;
    }catch(HibernateException e){
      rollback();
      throw e;
View Full Code Here

        new HibernateTxFragment(true, true) {
            protected void txFragment(Session session) throws Exception {
                // Delete the cluster node register.
                Query query = session.createQuery("delete from " + ClusterNode.class.getName() +" cn  where cn.id = :idNode");
                query.setLong("idNode", nodeId);
                query.executeUpdate();

                session.flush();
            }

            @Override
View Full Code Here

        try {
            transaction = session.beginTransaction();
            String nullCurrentWorkspacesSql = "update " + SqlUser.class.getSimpleName() + " set current_workspace_id = null where current_workspace_id = :workspaceId";
            Query query = session.createQuery(nullCurrentWorkspacesSql).setString("workspaceId", workspace.getWorkspaceId());
            session.delete(workspace);
            query.executeUpdate();
            transaction.commit();
        } catch (HibernateException e) {
            if (transaction != null) {
                transaction.rollback();
            }
View Full Code Here

  Query query = null;
  try {
      session = getSessionFactory().getCurrentSession();
      query = session.getNamedQuery(UPDATE_LAST_LOGIN);
      query.setParameter(USERNAME, username).setParameter(LAST_LOGIN, new Timestamp(new Date().getTime()));
      query.executeUpdate();
      LOG.debug("Last Login update successful >> updateLastLogin >> UserDetailsDAOImpl");
  }
  catch (Exception e) {
      LOG.error("Last Login update unsuccessful >> updateLastLogin >> UserDetailsDAOImpl");
      LOG.error("Exception occurred : " + e);
View Full Code Here

  parameterMap.put(UPDATE_DT, new Timestamp(new Date().getTime()));
  parameterMap.put(OBJ_ID, dto.getObjId());
  try {
      query = getNamedQuery(UPDATE_POST, parameterMap);

      query.executeUpdate();
  }
  catch (Exception e) {
      LOG.error("Error occured while updating the post: " + e);
  }
  finally {
View Full Code Here

                    Documents actor = (Documents) o;
                    System.out.println(actor.getTitle());
                }

                Query q1 = session.createSQLQuery("update Documents set title='qwe' where id=1;");
                q1.executeUpdate();

                session.getTransaction().commit();
            } catch (HibernateException he) {
                he.printStackTrace();
            }
View Full Code Here

      sessionFactory = HibernateSessionFactory.getInstance();
      session = sessionFactory.openSession();
      for (BOHistory history : project.getCurrentHistoryForProject()) {
        if (history.getHistoryAction() == HistoryAction.Delete && history.getHistoryTable() == HistoryTable.Tasks) {
          Query query = session.createQuery(strQuery + history.getHistoryItem());
          int rows = query.executeUpdate();
        }
      }
    } catch (Exception a_th) {
      throw new RuntimeException(a_th);
    } finally {
View Full Code Here

                protected void txFragment(Session session) throws Exception {
                    // Delete aggregated table columns
                    String deleteHql = "delete from " + DataSourceColumnEntry.class.getName() + " where datasource = :datasource";
                    Query deleteQuery = session.createQuery(deleteHql);
                    deleteQuery.setString("datasource", dsName);
                    deleteQuery.executeUpdate();

                    // Delete aggregated tables
                    deleteHql = "delete from "+ DataSourceTableEntry.class.getName() + " where datasource = :datasource";
                    deleteQuery = session.createQuery(deleteHql);
                    deleteQuery.setString("datasource", dsName);
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.