Java Code Examples for org.hibernate.Query.executeUpdate()

The following are Jave code examples for showing how to use executeUpdate() of the org.hibernate.Query class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: sjk   File: UserDaoImpl.java   Source Code and License Vote up 8 votes
@Override
public boolean deleteByIds(List<Integer> ids) {
    String hql = "delete User where id in (:ids)";
    Query query = getSession().createQuery(hql);
    query.setParameterList("ids", ids);
    return query.executeUpdate() == ids.size();
}
 
Example 2
Project: sjk   File: MarketAppDaoImpl.java   Source Code and License Vote up 6 votes
@Override
public int deleteByPK(Session sess, int id) {
    Query query = sess.createQuery("delete from MarketApp where id=:id");
    query.setInteger("id", id);
    int rows = query.executeUpdate();
    return rows;
}
 
Example 3
Project: sjk   File: AppDaoImpl.java   Source Code and License Vote up 6 votes
@Override
public int updateWeekDownload(Session session, int id) {
    String hql = "update App set LastWeekDelta =RealDownload - LastWeekDownload , LastWeekDownload = RealDownload where id = :id";
    Query query = session.createQuery(hql);
    query.setParameter("id", id);
    return query.executeUpdate();
}
 
Example 4
Project: sjk   File: AppAndTagDaoImpl.java   Source Code and License Vote up 5 votes
@Override
public int deleteByAppId(Session session, int appId) {
    final String queryString = "delete AppAndTag where appId = :appId";
    Query query = session.createQuery(queryString);
    query.setParameter("appId", appId);
    return query.executeUpdate();
}
 
Example 5
Project: sjk   File: AppDaoImpl.java   Source Code and License Vote up 5 votes
@Override
public int updateHide(Session sess, List<Integer> ids) {
    String hql = "update App set Hidden = 1 where id in (:ids)";
    Query query = sess.createQuery(hql);
    query.setParameterList("ids", ids);
    int num = query.executeUpdate();
    if (ids != null && ids.size() == num) {
        appHistory4IndexDaoImpl.updateAppStatus2Del(ids);
    }
    return num;
}
 
Example 6
Project: sjk   File: MoAppAndTagDaoImpl.java   Source Code and License Vote up 5 votes
@Override
public int deleteByAppId(Session session, int appId) {
    final String queryString = "delete MoAppAndTag where appId = :appId";
    Query query = session.createQuery(queryString);
    query.setParameter("appId", appId);
    return query.executeUpdate();
}
 
Example 7
Project: sjk   File: AppHistory4IndexDaoImpl.java   Source Code and License Vote up 5 votes
/**
 * 设置appStatus 状态 为可删除 状态 3,索引状态 indexStatus为 -1
 */
@Override
public int updateAppStatus2Del(List<Integer> ids) {
    String hql = "update AppHistory4Index set appStatus=3,indexStatus=-1,lastOpTime=:lastOpTime where appId in (:appIds)";
    Query query = this.getSession().createQuery(hql);
    query.setParameterList("appIds", ids);
    query.setTimestamp("lastOpTime", new Date());

    return query.executeUpdate();

}
 
Example 8
Project: sjk   File: AppAndTagDaoImpl.java   Source Code and License Vote up 5 votes
@Override
public int deleteByAppIdAndTagType(List<Integer> appIds, short tagType) {
    String queryString = "delete AppAndTag where appId in (:appIds) and tagType = :tagType";
    Query query = getSession().createQuery(queryString);
    query.setParameterList("appIds", appIds);
    query.setParameter("tagType", tagType);
    return query.executeUpdate();
}
 
Example 9
Project: sjk   File: RollinfoDaoImpl.java   Source Code and License Vote up 5 votes
@Override
public int deleteNotExistsApp(Session session) {
    StringBuilder hql = new StringBuilder("delete from Rollinfo where not exists (");
    hql.append(" select 1 from App x");
    hql.append(" where x.id = appId");
    hql.append(")");
    Query query = session.createQuery(hql.toString());
    int effected = query.executeUpdate();
    return effected;
}
 
Example 10
Project: sjk   File: MoMixFeaturedDaoImpl.java   Source Code and License Vote up 5 votes
@Override
public int updateShow(List<Integer> ids) {
    String hql = "update MoMixFeatured set Hidden = 0 where id in (:ids)";
    Query query = getSession().createQuery(hql);
    query.setParameterList("ids", ids);
    return query.executeUpdate();
}
 
Example 11
Project: sjk   File: AppDaoImpl.java   Source Code and License Vote up 5 votes
@Override
public int editCatalog(List<Integer> ids, short catalog, int subCatalog) {
    String hql = "update App set catalog = :catalog , subCatalog = :subCatalog , auditCatalog = 1 where id in (:ids)";
    Query query = getSession().createQuery(hql);
    query.setParameterList("ids", ids);
    query.setParameter("catalog", catalog);
    query.setParameter("subCatalog", subCatalog);
    return query.executeUpdate();
}
 
Example 12
Project: sjk   File: AppDaoImpl.java   Source Code and License Vote up 5 votes
@Override
public int updateDayDownload(Session session, int id) {
    String hql = "update App set LastDayDelta =RealDownload - LastDayDownload , LastDayDownload = RealDownload where id = :id";
    Query query = session.createQuery(hql);
    query.setParameter("id", id);
    return query.executeUpdate();
}
 
Example 13
Project: sjk   File: MoMixFeaturedDaoImpl.java   Source Code and License Vote up 5 votes
@Override
public int delete(int id) {
    Query query = getSession().createQuery("delete from MoMixFeatured where id=:id");
    query.setInteger("id", id);
    int rows = query.executeUpdate();
    return rows;
}
 
Example 14
Project: sjk   File: RollinfoDaoImpl.java   Source Code and License Vote up 5 votes
@Override
public int delete(List<Integer> appIds) {
    String hql = "delete Rollinfo where appId in (:ids)";
    Query query = getSession().createQuery(hql);
    query.setParameterList("ids", appIds);
    int effected = query.executeUpdate();
    return effected;
}
 
Example 15
Project: Equella   File: AddExtraRemoteRepoColumns.java   Source Code and License Vote up 5 votes
@Override
protected void executeDataMigration(HibernateMigrationHelper helper, MigrationResult result, Session session)
{
	Query setDenyQuery = session.createQuery("UPDATE ItemDefinition SET denyDirectContribution = :value");
	setDenyQuery.setParameter("value", false);

	Query setDisabledQuery = session.createQuery("UPDATE FederatedSearch SET disabled = :value");
	setDisabledQuery.setParameter("value", false);

	setDenyQuery.executeUpdate();
	setDisabledQuery.executeUpdate();
}
 
Example 16
Project: sjk   File: MoAppAndTagDaoImpl.java   Source Code and License Vote up 5 votes
@Override
public int deleteByMoAppIdAndTagType(List<Integer> appIds, short tagType) {
    String queryString = "delete MoAppAndTag where appId in (:appIds) and tagType = :tagType";
    Query query = getSession().createQuery(queryString);
    query.setParameterList("appIds", appIds);
    query.setParameter("tagType", tagType);
    return query.executeUpdate();
}
 
Example 17
Project: sjk   File: MoFeaturedDaoImpl.java   Source Code and License Vote up 5 votes
@Override
public int updateHide(List<Integer> ids) {
    String hql = "update MoFeatured set Hidden = 1 where id in (:ids)";
    Query query = getSession().createQuery(hql);
    query.setParameterList("ids", ids);
    return query.executeUpdate();
}
 
Example 18
Project: EBwn2_ForOpenShift   File: Update.java   Source Code and License Vote up 4 votes
synchronized public static boolean updateRating(String ... vals)
{
         int chk=0;
         int nor=0;
         sf=Logic.getSf();
         Session s = null;
         try{
                s=sf.openSession();
                s.beginTransaction();
                Query qry=s.createQuery("update UserRatings ur set ur.rat=:rating, ur.comm=:comment where ur.rat_id=:rid");
                qry.setParameter("rid", vals[0]);
                qry.setParameter("rating", vals[1]);
                qry.setParameter("comment", vals[2]);
                nor=qry.executeUpdate();
                System.out.println("No. Of rows updated="+nor);
                s.getTransaction().commit();
            }catch (Exception e)
                 {
                         chk=-1;
                          System.out.println("HibernateException Occured!!"+e);
                         e.printStackTrace();
                 }
            finally
                 {
                         if(s!=null)
                         {
                              s.clear();
                              s.close();
                         }
                 }
            if(chk==0)
            {
                 if(nor!=0)
                 {
                      return (true);
                 }
                 else
                 {
                      return (false);
                 }
            }
            else
            {
                 return (false);
            }
}
 
Example 19
Project: EBwn2_ForOpenShift   File: Update.java   Source Code and License Vote up 4 votes
synchronized public static boolean updateUserPhone(String ... vals)
{
         int chk=0;
         int nor=0;
         sf=Logic.getSf();
         Session s = null;
         try{
                s=sf.openSession();
                s.beginTransaction();
                Query qry=s.createQuery("update UserDetails ud set ud.mob_no=:mobno where ud.usr_id=:uid");
                qry.setParameter("uid", vals[0]);
                qry.setParameter("mobno", vals[1]);
                nor=qry.executeUpdate();
                System.out.println("No. Of rows updated="+nor);
                s.getTransaction().commit();
            }catch (Exception e)
                 {
                         chk=-1;
                          System.out.println("HibernateException Occured!!"+e);
                         e.printStackTrace();
                 }
            finally
                 {
                         if(s!=null)
                         {
                              s.clear();
                              s.close();
                         }
                 }
            if(chk==0)
            {
                 if(nor!=0)
                 {
                      return (true);
                 }
                 else
                 {
                      return (false);
                 }
            }
            else
            {
                 return (false);
            }
}
 
Example 20
Project: Celebino   File: GenericDao.java   Source Code and License Vote up 3 votes
public int delete(String fieldIdName, String fieldIdValue) throws SQLException {
	int resultado = 0;

	String className = getEntityClass().getName();

	Session session = HibernateUtil.getSessionFactory().openSession();

	try {
		session.beginTransaction();

		Query query = session.createQuery("delete " + className + " where " + fieldIdName + " = :fieldValue");

		query.setParameter("fieldValue", fieldIdValue);

		resultado = query.executeUpdate();

		session.getTransaction().commit();

	} catch (HibernateException hibernateException) {
		session.getTransaction().rollback();

		throw new SQLException(hibernateException);

	} finally {
		session.close();
	}

	return resultado;
}