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


Java SQLQuery.setInteger方法代码示例

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


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

示例1: updateBySql

import org.hibernate.SQLQuery; //导入方法依赖的package包/类
public void updateBySql(String sql, Object[] vals) {
	Session session = hibernateTemplate.getSessionFactory().openSession();
	
	org.hibernate.Transaction tx = session.beginTransaction();
	
	SQLQuery query = session.createSQLQuery(sql);
	if(vals != null) {
		for(int i=0;i<vals.length;i++) {
			if(vals[i] instanceof Integer) {
				query.setInteger(i, (Integer)vals[i]);
			} else {
				query.setString(i, vals[i].toString());
			}
		}
	}
	query.executeUpdate();
	
	try {
		tx.commit();
	} catch (Exception e) {
		e.printStackTrace();
		tx.rollback();
	}
	session.close(); 
}
 
开发者ID:lrxzl,项目名称:djpt,代码行数:26,代码来源:DaoImpl.java

示例2: isLessonLearner

import org.hibernate.SQLQuery; //导入方法依赖的package包/类
@Override
   public boolean isLessonLearner(Long lessonId, Integer userId) {
SQLQuery query = getSession().createSQLQuery(SecurityDAO.CHECK_LESSON_LEARNER);
query.setLong(0, lessonId);
query.setInteger(1, userId);
return !query.list().isEmpty();
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:SecurityDAO.java

示例3: findBySql

import org.hibernate.SQLQuery; //导入方法依赖的package包/类
public <T> List<T> findBySql(String sql, Object[] vals, int from_id, int len) {
	Session session = hibernateTemplate.getSessionFactory().openSession();
	org.hibernate.Transaction tx = session.beginTransaction(); 
	
	SQLQuery query = session.createSQLQuery(sql);
	if(vals != null) {
		for(int i=0;i<vals.length;i++) {
			if(vals[i] instanceof Integer) {
				query.setInteger(i, (Integer) vals[i]);
			} else {
				query.setString(i, vals[i].toString());
			}
		}
	}
	
	if(len>0) {
		query.setFirstResult(from_id);
		query.setMaxResults(len-1);
	}
	
	try {
		tx.commit();
		return query.list();
	} catch (Exception e) {
		e.printStackTrace();
		tx.rollback();
		return null;
	} finally {
		session.close(); 
	}
	
}
 
开发者ID:lrxzl,项目名称:djpt,代码行数:33,代码来源:DaoImpl.java

示例4: getForfeitByReader

import org.hibernate.SQLQuery; //导入方法依赖的package包/类
@Override
public List<ForfeitInfo> getForfeitByReader(Reader reader) {
	// TODO Auto-generated method stub
	String hql = "SELECT f.borrowId,f.forfeit,f.isPay,f.aid FROM forfeitinfo  f,borrowinfo  b where  b.borrowId = f.borrowId and b.readerId =?";
	List list = null;
	try{
		Session session = this.getSession();
		SQLQuery createSQLQuery = session.createSQLQuery(hql);
		createSQLQuery.setInteger(0, reader.getReaderId());
		list = createSQLQuery.list();
		if(list!=null){
			List<ForfeitInfo> infos = new ArrayList<ForfeitInfo>();
			for(int i = 0;i<list.size();i++){
				Object[] objects = (Object[]) list.get(i);
				Integer borrowId = (Integer) objects[0];
				Double forfeit = (Double) objects[1];
				Integer isPay = (Integer) objects[2];
				Integer aid = (Integer) objects[3];
				Admin admin = new Admin();
				admin.setAid(aid);
				BorrowInfo info = new BorrowInfo();
				info.setBorrowId(borrowId);
				ForfeitInfo forfeitInfo = new ForfeitInfo();
				forfeitInfo.setAdmin(admin);
				forfeitInfo.setBorrowId(borrowId);
				forfeitInfo.setForfeit(forfeit);
				forfeitInfo.setIsPay(isPay);
				infos.add(forfeitInfo);
			}
			return infos;
		}
	}catch (Throwable e) {
		e.printStackTrace();
		throw new RuntimeException(e.getMessage());
	}
	return null;
}
 
开发者ID:cckevincyh,项目名称:LibrarySystem,代码行数:38,代码来源:ForfeitDaoImpl.java

示例5: quOrderByIdAdd1

import org.hibernate.SQLQuery; //导入方法依赖的package包/类
/**
 * 更新orderbyId
 * 属性 belongId所有题目,只要大于等于orderById+1
 * @param belongId
 * @param orderById
 */
private void quOrderByIdAdd1(String belongId,Integer orderById){
	if(belongId!=null && !"".equals(belongId)){
		String sql="update t_question set order_by_id=order_by_id+1 where belong_id=? and order_by_id>=?";
		//更新排序号
		SQLQuery query=this.getSession().createSQLQuery(sql);
		query.setString(0, belongId);
		query.setInteger(1, orderById);
		query.executeUpdate();
	}
}
 
开发者ID:wkeyuan,项目名称:DWSurvey,代码行数:17,代码来源:QuestionDaoImpl.java

示例6: quOrderByIdDel1

import org.hibernate.SQLQuery; //导入方法依赖的package包/类
public void quOrderByIdDel1(String belongId,Integer orderById){
	if(belongId!=null && !"".equals(belongId)){
		String sql="update t_question set order_by_id=order_by_id-1 where belong_id=? and order_by_id>=?";
		//更新排序号
		SQLQuery query=this.getSession().createSQLQuery(sql);
		query.setString(0, belongId);
		query.setInteger(1, orderById);
		query.executeUpdate();
	}
}
 
开发者ID:wkeyuan,项目名称:DWSurvey,代码行数:11,代码来源:QuestionDaoImpl.java

示例7: quOrderByIdDel1

import org.hibernate.SQLQuery; //导入方法依赖的package包/类
public void quOrderByIdDel1(String quId,Integer orderById){
	if(quId!=null && !"".equals(quId)){
		String sql="update t_qu_radio set order_by_id=order_by_id-1 where qu_id=? and order_by_id>=?";
		//更新排序号
		SQLQuery query=this.getSession().createSQLQuery(sql);
		query.setString(0, quId);
		query.setInteger(1, orderById);
		query.executeUpdate();
	}
}
 
开发者ID:wkeyuan,项目名称:DWSurvey,代码行数:11,代码来源:QuRadioDaoImpl.java


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