当前位置: 首页>>代码示例>>Java>>正文


Java Query.setInteger方法代码示例

本文整理汇总了Java中org.hibernate.Query.setInteger方法的典型用法代码示例。如果您正苦于以下问题:Java Query.setInteger方法的具体用法?Java Query.setInteger怎么用?Java Query.setInteger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.Query的用法示例。


在下文中一共展示了Query.setInteger方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateValueOfKey

import org.hibernate.Query; //导入方法依赖的package包/类
@Override
public boolean updateValueOfKey(Constant constant) { 
		Session session = HibernateUtils.getSession();
		 Transaction tx = session.beginTransaction();
		 boolean isUpdate = false;
		 try {
			Query query = session.createQuery("update Constant c set c.value =? where c.id = ?");  
		    query.setString(0,constant.getValue());
		    query.setInteger(1, constant.getId()); 
			int temp = query.executeUpdate();  
			tx.commit();
			if (temp>0) {
				isUpdate = true;
			}
		} catch (Exception e) {
			 e.printStackTrace();
			 tx.rollback();
		}finally {
			HibernateUtils.closeSession();
		}   
		 return isUpdate;
}
 
开发者ID:codekongs,项目名称:ImageClassify,代码行数:23,代码来源:ConstantService.java

示例2: updateAppStatus2Del

import org.hibernate.Query; //导入方法依赖的package包/类
@Override
public int updateAppStatus2Del(Integer id) {
    Session session = null;

    try {
        session = this.sessions.openSession();
        //
        String hql = "update AppHistory4Index set appStatus=3,indexStatus=-1,lastOpTime=:lastOpTime where appId =:appId";
        Query query = session.createQuery(hql);
        query.setInteger("appId", id);
        query.setTimestamp("lastOpTime", new Date());

        return query.executeUpdate();

    } catch (Exception e) {
        logger.error("error:", e);
        return 0;
    } finally {
        if (session != null && session.isOpen()) {
            session.flush();
            session.clear();
            session.close();
        }
    }
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:26,代码来源:AppHistory4IndexDaoImpl.java

示例3: updateMark

import org.hibernate.Query; //导入方法依赖的package包/类
@Override
public boolean updateMark(Mark mark) {
	Session session = HibernateUtils.getSession();
	 Transaction tx = session.beginTransaction();
	 try {
		Query query = session.createQuery("update Mark m set m.mark_accuracy =? where m.user_id = ? and m.img_id = ?");  
	    query.setString(0, mark.getMark_accuracy());
	    query.setInteger(1, mark.getUser_id());
	    query.setInteger(2, mark.getImg_id()); 
		query.executeUpdate();  
		tx.commit();
		return true;
	} catch (Exception e) {
		 e.printStackTrace();
		 tx.rollback();
		 return false;
	}finally {
		HibernateUtils.closeSession();
	} 
}
 
开发者ID:codekongs,项目名称:ImageClassify,代码行数:21,代码来源:MarkService.java

示例4: updateAccuracy

import org.hibernate.Query; //导入方法依赖的package包/类
@Override
public boolean updateAccuracy(User user) {
	Session session = HibernateUtils.getSession();
	 Transaction tx = session.beginTransaction();
	 try {
		Query query = session.createQuery("update User u set u.accuracy =? where u.user_id = ?");  
	    query.setString(0, user.getAccuracy());
	    query.setInteger(1, user.getUser_id()); 
		query.executeUpdate();  
		tx.commit();
		return true;
	} catch (Exception e) {
		 e.printStackTrace();
		 tx.rollback();
		 return false;
	}finally {
		HibernateUtils.closeSession();
	}  
}
 
开发者ID:codekongs,项目名称:ImageClassify,代码行数:20,代码来源:UserService.java

示例5: deleteInterests

import org.hibernate.Query; //导入方法依赖的package包/类
@Override
public int deleteInterests(int user_id) {  
			Session session = HibernateUtils.getSession(); //生成session实例
		    Transaction tx = session.beginTransaction();  //创建transaction实例 
		    int temp = 0;
		    try {  
		    	String hql = "delete from Interest where user_id  =  ?"; 
		    	Query query = session.createQuery(hql);
		    	query.setInteger(0, user_id);  
		    	temp = query.executeUpdate(); 
		    	tx.commit();            //提交事务  
			} catch (Exception e) {
				e.printStackTrace();
				tx.rollback();   
			}finally {
			  HibernateUtils.closeSession();  //关闭Session实例
			} 
		    return temp;
}
 
开发者ID:codekongs,项目名称:ImageClassify,代码行数:20,代码来源:InterestService.java

示例6: deleteInterest

import org.hibernate.Query; //导入方法依赖的package包/类
@Override
public int deleteInterest(int user_id, int category_id) {
	Session session = HibernateUtils.getSession(); //生成session实例
    Transaction tx = session.beginTransaction();  //创建transaction实例 
    int temp = 0;
    try {  
    	String hql = "delete from Interest where user_id  = ? and category_id = ?"; 
    	Query query = session.createQuery(hql);
    	query.setInteger(0, user_id);  
    	query.setInteger(1, category_id);
    	temp = query.executeUpdate(); 
    	tx.commit();            //提交事务  
	} catch (Exception e) {
		e.printStackTrace();
		tx.rollback();   
	}finally {
	  HibernateUtils.closeSession();  //关闭Session实例
	} 
    return temp;
}
 
开发者ID:codekongs,项目名称:ImageClassify,代码行数:21,代码来源:InterestService.java

示例7: deleteByPK

import org.hibernate.Query; //导入方法依赖的package包/类
@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;
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:8,代码来源:MarketAppDaoImpl.java

示例8: deleteByMarketApp

import org.hibernate.Query; //导入方法依赖的package包/类
@Override
public int deleteByMarketApp(Session sess, int foreignKey) {
    Query query = sess.createQuery("delete from App where marketAppId=:marketAppId");
    query.setInteger("marketAppId", foreignKey);
    int rows = query.executeUpdate();
    return rows;
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:8,代码来源:AppDaoImpl.java

示例9: getChannelApp

import org.hibernate.Query; //导入方法依赖的package包/类
@Override
public MonUserChannelApp getChannelApp(String marketName, Integer apkId) {
    Query query = getSession().createQuery(
            "from MonUserChannelApp m where  m.apkId=:apkId  and m.marketName=:marketName ");
    query.setString("marketName", marketName);
    query.setInteger("apkId", apkId);
    List<MonUserChannelApp> list = HibernateHelper.list(query);
    if (list == null || list.size() == 0) {
        return null;
    } else {
        return list.get(0);
    }
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:14,代码来源:MonUserChannelAppDaoImpl.java

示例10: listLogByUserId

import org.hibernate.Query; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public List<SysLog> listLogByUserId(int userId) {
	String sql = "from SysLog where user.id=:userId";
	Session session = sessionFactory.getCurrentSession();
	Query query = session.createQuery(sql);
	query.setInteger("userId", userId);
	List<SysLog> sysLogs = query.list();
	return sysLogs;
}
 
开发者ID:zhangjikai,项目名称:sdudoc,代码行数:11,代码来源:LogDaoImpl.java

示例11: getCountCoursesByParentCourseAndTypeAndState

import org.hibernate.Query; //导入方法依赖的package包/类
@Override
   public int getCountCoursesByParentCourseAndTypeAndState(Integer parentOrgId, Integer typeId, Integer stateId,
    String searchString) {
Query query = getSession().createQuery(OrganisationDAO.GET_COUNT_COURSES_BY_PARENT_TYPE_STATE);
query.setInteger("parentOrgId", parentOrgId);
query.setInteger("typeId", typeId);
query.setInteger("stateId", stateId);
// support for custom search from a toolbar
searchString = searchString == null ? "" : searchString;
query.setString("searchString", searchString);

return ((Number) query.uniqueResult()).intValue();
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:OrganisationDAO.java

示例12:

import org.hibernate.Query; //导入方法依赖的package包/类
@Override
public Collect getCollectByBook$User(int bookId, int userId) {
	String sql = "from Collect where bookId=:bookId and userId=:userId";
	Session session = sessionFactory.getCurrentSession();
	Query query = session.createQuery(sql);
	query.setInteger("bookId", bookId);
	query.setInteger("userId", userId);
	List<Collect> collects = query.list();
	if(collects.size() == 0)
		return null;
	return collects.get(0);
}
 
开发者ID:zhangjikai,项目名称:sdudoc,代码行数:13,代码来源:CollectDaoImpl.java

示例13: getPagedCourses

import org.hibernate.Query; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
   @Override
   public List<Organisation> getPagedCourses(Integer parentOrgId, Integer typeId, Integer stateId, int page, int size,
    String sortBy, String sortOrder, String searchString) {
String sortByParam = "o.name";
switch (sortBy) {
    case "id":
	sortByParam = "o.organisationId";
	break;
    case "name":
	sortByParam = "o.name";
	break;
    case "code":
	sortByParam = "o.code";
	break;
    case "description":
	sortByParam = "o.createDate";
	break;
}

Query query = getSession().createQuery(OrganisationDAO.GET_PAGED_COURSES + sortByParam + " " + sortOrder);
query.setInteger("typeId", typeId);
query.setInteger("stateId", stateId);
query.setInteger("parentOrgId", parentOrgId);
// support for custom search from a toolbar
searchString = searchString == null ? "" : searchString;
query.setString("searchString", searchString);
query.setFirstResult(page * size);
query.setMaxResults(size);
return query.list();
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:OrganisationDAO.java

示例14: updateDicValue

import org.hibernate.Query; //导入方法依赖的package包/类
@Override
public int updateDicValue(Integer id, Integer intValue) {
    String hql = "update SysDictionary set IntValue =:intValue where id =:id";
    Query query = getSession().createQuery(hql);
    query.setInteger("intValue", intValue);
    query.setInteger("id", id);
    return query.executeUpdate();
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:9,代码来源:SysDictionaryDaoImpl.java

示例15: delete

import org.hibernate.Query; //导入方法依赖的package包/类
@Override
public int delete(int id) {
    Query query = getSession().createQuery("delete from Metro where id=:id");
    query.setInteger("id", id);
    int rows = query.executeUpdate();
    return rows;
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:8,代码来源:MetroDaoImpl.java


注:本文中的org.hibernate.Query.setInteger方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。