本文整理汇总了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();
}
示例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();
}
示例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();
}
}
示例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;
}
示例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();
}
}
示例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();
}
}
示例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();
}
}