本文整理汇总了Java中org.hibernate.Query.setParameterList方法的典型用法代码示例。如果您正苦于以下问题:Java Query.setParameterList方法的具体用法?Java Query.setParameterList怎么用?Java Query.setParameterList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.Query
的用法示例。
在下文中一共展示了Query.setParameterList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateAppHistory4indeToIndexed
import org.hibernate.Query; //导入方法依赖的package包/类
/**
* 更新 状态到数据库,仅针对 appStatus 为 1(add) 2(update) 更新索引 ,
*/
@Override
public int updateAppHistory4indeToIndexed(List<Integer> appIds) {
String hql = "update AppHistory4Index set indexStatus=1,lastIndexTime=:lastIndexTime where (appStatus=1 or appStatus=2) and appId in (:appIds)";
Session session = null;
try {
session = this.sessions.openSession();
Query query = session.createQuery(hql);
query.setParameterList("appIds", appIds);
query.setTimestamp("lastIndexTime", 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();
}
}
}
示例2: selectByHQL
import org.hibernate.Query; //导入方法依赖的package包/类
@SuppressWarnings( "unchecked" )
@Override
public < T > List< T > selectByHQL( String _db , String _hql , String[] _param , Object[] _value, Class< T > _cls ){
Session sess = _get_session( _db );
try {
Query query = _get_session( _db ).createQuery( _hql );
if ( _param != null && _value != null ) {
for( int i = 0; i < _param.length; i ++ ){
if( _value[i] instanceof Collection )
query.setParameterList( _param[i] , ( Collection<?> ) _value[i] );
else
query.setParameter( _param[i] ,_value[i] );
}
}
return query.list();
} finally {
_flush_session( sess );
}
}
示例3: deleteByIds
import org.hibernate.Query; //导入方法依赖的package包/类
@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();
}
示例4: updateDownload
import org.hibernate.Query; //导入方法依赖的package包/类
@Override
public int updateDownload(List<Integer> ids, Integer realDownload, int deltaDownload) {
String hql = null;
if (realDownload != null) {
hql = "update App set realDownload = :realDownload , deltaDownload = :deltaDownload, downloadRank = :downloadRank where id in (:id)";
} else {
hql = "update App set deltaDownload = :deltaDownload, downloadRank = realDownload + :deltaDownload where id in (:id)";
}
Query query = getSession().createQuery(hql);
if (realDownload != null) {
query.setParameter("realDownload", realDownload);
query.setParameter("downloadRank", realDownload.intValue() + deltaDownload);
}
query.setParameter("deltaDownload", deltaDownload);
query.setParameterList("id", ids);
return query.executeUpdate();
}
示例5: deleteByIds
import org.hibernate.Query; //导入方法依赖的package包/类
@Override
public int deleteByIds(List<Integer> ids) {
String hql = "delete App where id in (:ids)";
Query query = getSession().createQuery(hql);
query.setParameterList("ids", ids);
return query.executeUpdate();
}
示例6: updateDeleted
import org.hibernate.Query; //导入方法依赖的package包/类
@Override
public Boolean updateDeleted(List<Integer> ids, boolean deleted) {
String hql = "update MoFeatured set Deleted =:deleted where id in (:ids)";
Query query = getSession().createQuery(hql);
query.setBoolean("deleted", deleted);
query.setParameterList("ids", ids);
return query.executeUpdate() > 0;
}
示例7: getByIds
import org.hibernate.Query; //导入方法依赖的package包/类
@Override
public List<MarketApp> getByIds(Session session, List<Integer> ids) {
StringBuilder queryString = new StringBuilder("from MarketApp where id in (:ids)");
Query q = session.createQuery(queryString.toString());
q.setParameterList("ids", ids);
List<MarketApp> list = HibernateHelper.list(q);
return list;
}
示例8: deleteByIds
import org.hibernate.Query; //导入方法依赖的package包/类
@Override
public int deleteByIds(List<Integer> ids) {
String hql = "delete Tag where id in (:ids)";
Query query = getSession().createQuery(hql);
query.setParameterList("ids", ids);
return query.executeUpdate();
}
示例9: updateAppStatus2Del
import org.hibernate.Query; //导入方法依赖的package包/类
/**
* 设置appStatus 状态 为可删除 状态 3,索引状态 indexStatus为 -1
*/
@Override
public int updateAppStatus2Del(List<Integer> ids) {
Session session = null;
try {
session = this.sessions.openSession();
String hql = "update AppHistory4Index set appStatus=3,indexStatus=-1,lastOpTime=:lastOpTime where appId in (:appIds)";
Query query = session.createQuery(hql);
query.setParameterList("appIds", ids);
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();
}
}
}
示例10: applyNamedParameterToQuery
import org.hibernate.Query; //导入方法依赖的package包/类
/**
* Apply the given name parameter to the given Query object.
* @param queryObject the Query object
* @param paramName the name of the parameter
* @param value the value of the parameter
* @throws HibernateException if thrown by the Query object
*/
protected void applyNamedParameterToQuery(Query queryObject, String paramName, Object value)
throws HibernateException {
if (value instanceof Collection) {
queryObject.setParameterList(paramName, (Collection<?>) value);
}
else if (value instanceof Object[]) {
queryObject.setParameterList(paramName, (Object[]) value);
}
else {
queryObject.setParameter(paramName, value);
}
}
示例11: getAppList
import org.hibernate.Query; //导入方法依赖的package包/类
@Override
public List<TopAppVo> getAppList(Set<String> pnames) {
// String names = "";
// StringBuilder sb = new StringBuilder();
// for (String name : pnames) {
// sb.append("'" + name + "'" + ",");
// }
// names = sb.toString().substring(0, sb.toString().length() - 1);
// names = "'com.tencent.mobileqq'";
// // System.out.println("--> " + names);
// return this.jdbcTemplate.query(this.top2000sql,
// this.TopAppVoRowMapper, names);
Query query = getSession().createSQLQuery(this.top2000sql);
query.setParameterList("ids", pnames);
List<Object[]> lists = HibernateHelper.list(query);
List<TopAppVo> volist = new ArrayList<TopAppVo>();
for (Object[] obj : lists) {
TopAppVo vo = new TopAppVo();
vo.setId((Integer) obj[0]);
vo.setName((String) obj[1]);
vo.setPkname((String) obj[2]);
vo.setLastUpdateTime((Date)obj[3]);
volist.add(vo);
}
return volist;
}
示例12: delAppHistory4index
import org.hibernate.Query; //导入方法依赖的package包/类
@Override
public int delAppHistory4index(List<Integer> appIds) {
// String hql =
// "delete AppHistory4Index where appStatus=3 and indexStatus=-1 and appId in (:appIds)";
// 删除前一天生成索引的数据,避免数据过多
String hql = "delete AppHistory4Index where (indexStatus=-1 and appId in (:appIds) ) or lastIndexTime<:lastIndexTime";
Session session = null;
try {
session = this.sessions.openSession();
Query query = session.createQuery(hql);
query.setParameterList("appIds", appIds);
query.setTimestamp("lastIndexTime", DateUtils.addDays(new Date(), -1));// 删除前一天索引后的数据
return query.executeUpdate();
} catch (Exception e) {
logger.error("error:", e);
return 0;
} finally {
if (session != null && session.isOpen()) {
session.flush();
session.clear();
session.close();
}
}
}
示例13: deleteByMarketApps
import org.hibernate.Query; //导入方法依赖的package包/类
@Override
public int deleteByMarketApps(Session session, List<Integer> marketAppIds) {
String hql = "delete App where marketAppId in (:marketAppIds)";
Query query = session.createQuery(hql);
query.setParameterList("marketAppIds", marketAppIds);
return query.executeUpdate();
}
示例14: createModel
import org.hibernate.Query; //导入方法依赖的package包/类
public static TimetableGridModel createModel(String solutionIdsStr, StudentGroupInfo g, org.hibernate.Session hibSession, TimetableGridContext context) {
TimetableGridModel model = new TimetableGridModel(ResourceType.STUDENT_GROUP.ordinal(), g.getGroupId());
model.setName(g.getGroupName());
model.setFirstDay(context.getFirstDay());
model.setFirstSessionDay(context.getFirstSessionDay());
model.setFirstDate(context.getFirstDate());
List<Long> classIds = new ArrayList<Long>();
for (StudentGroupInfo.ClassInfo clazz: g.getGroupAssignments())
classIds.add(clazz.getClassId());
if (classIds.isEmpty()) return null;
Query q = hibSession.createQuery(
"select distinct a from Assignment a where a.solution.uniqueId in ("+solutionIdsStr+") and a.classId in (:classIds)");
q.setParameterList("classIds", classIds, new LongType());
q.setCacheable(true);
List assignments = q.list();
model.setSize((int)Math.round(g.countStudentWeights()));
for (Iterator i = assignments.iterator(); i.hasNext(); ) {
Assignment assignment = (Assignment)i.next();
List<TimetableGridCell> cells = createCells(model, assignment, hibSession, context, false);
StudentGroupInfo.ClassInfo ci = g.getGroupAssignment(assignment.getClassId());
if (ci != null) {
int total = g.countStudentsOfOffering(assignment.getClazz().getSchedulingSubpart().getInstrOfferingConfig().getInstructionalOffering().getUniqueId());
for (TimetableGridCell cell: cells) {
cell.setGroup("(" + Math.round(ci.countStudentsWeight()) + ")");
if (ci.getStudents() != null && !ci.getStudents().isEmpty() && total > 1) {
int assigned = ci.getStudents().size();
int minLimit = assignment.getClazz().getExpectedCapacity();
int maxLimit = assignment.getClazz().getMaxExpectedCapacity();
int limit = maxLimit;
if (minLimit < maxLimit) {
int roomLimit = (int) Math.floor(assignment.getPlacement().getRoomSize() / (assignment.getClazz().getRoomRatio() == null ? 1.0f : assignment.getClazz().getRoomRatio()));
// int roomLimit = Math.round((c.getRoomRatio() == null ? 1.0f : c.getRoomRatio()) * p.getRoomSize());
limit = Math.min(Math.max(minLimit, roomLimit), maxLimit);
}
if (assignment.getClazz().getSchedulingSubpart().getInstrOfferingConfig().isUnlimitedEnrollment() || limit >= 9999) limit = Integer.MAX_VALUE;
int p = 100 * assigned / Math.min(limit, total);
cell.setBackground(percentage2color(p));
cell.setPreference(assigned + " of " + total);
}
}
}
}
model.setUtilization(g.getGroupValue());
return model;
}
示例15: print
import org.hibernate.Query; //导入方法依赖的package包/类
public static boolean print(OutputStream out, Collection<SubjectArea> subjectAreas, String courseNumber) throws IOException, DocumentException {
TreeSet courses = new TreeSet(new Comparator() {
public int compare(Object o1, Object o2) {
CourseOffering co1 = (CourseOffering)o1;
CourseOffering co2 = (CourseOffering)o2;
int cmp = co1.getCourseName().compareTo(co2.getCourseName());
if (cmp!=0) return cmp;
return co1.getUniqueId().compareTo(co2.getUniqueId());
}
});
List<Long> subjectIds = new ArrayList<Long>();
for (SubjectArea sa: subjectAreas)
subjectIds.add(sa.getUniqueId());
String query = "select co from CourseOffering co where co.subjectArea.uniqueId in :subjectIds";
if (courseNumber != null && !courseNumber.trim().isEmpty()) {
if (courseNumber.indexOf('*') >= 0) {
query += " and co.courseNbr like :courseNbr ";
} else {
query += " and co.courseNbr = :courseNbr ";
}
}
Query q = new SessionDAO().getSession().createQuery(query);
q.setParameterList("subjectIds", subjectIds);
if (courseNumber != null && !courseNumber.trim().isEmpty())
q.setParameter("courseNbr", ApplicationProperty.CourseOfferingNumberUpperCase.isTrue()? courseNumber.trim().replace('*', '%').toUpperCase() : courseNumber.trim().replace('*', '%'));
courses.addAll(q.list());
if (courses.isEmpty()) return false;
PdfWorksheet w = new PdfWorksheet(out, subjectAreas, courseNumber);
for (Iterator i=courses.iterator();i.hasNext();) {
w.print((CourseOffering)i.next());
}
w.lastPage();
w.close();
return true;
}