List of usage examples for org.hibernate Query setParameterList
Query<R> setParameterList(int position, Object[] values);
From source file:org.apache.ctakes.ytex.kernel.dao.ClassifierEvaluationDaoImpl.java
License:Apache License
public Map<String, FeatureRank> getFeatureRanks(Set<String> featureNames, String corpusName, String featureSetName, String label, String evaluationType, Integer foldId, double param1, String param2) {/*from w ww . j a v a2s .co m*/ Query q = prepareUniqueFeatureEvalQuery(corpusName, featureSetName, label, evaluationType, foldId, param1, param2, "getFeatureRankEvaluations"); q.setParameterList("featureNames", featureNames); @SuppressWarnings("unchecked") List<FeatureRank> featureRanks = q.list(); Map<String, FeatureRank> frMap = new HashMap<String, FeatureRank>(featureRanks.size()); for (FeatureRank fr : featureRanks) frMap.put(fr.getFeatureName(), fr); return frMap; }
From source file:org.apache.ctakes.ytex.kernel.dao.ClassifierEvaluationDaoImpl.java
License:Apache License
public Map<String, Double> getFeatureRankEvaluations(Set<String> featureNames, String corpusName, String featureSetName, String label, String evaluationType, Integer foldId, double param1, String param2) {// w ww .j av a 2 s . c o m Query q = prepareUniqueFeatureEvalQuery(corpusName, featureSetName, label, evaluationType, foldId, param1, param2, "getFeatureRankEvaluations"); q.setParameterList("featureNames", featureNames); List<FeatureRank> featureRanks = q.list(); Map<String, Double> evalMap = new HashMap<String, Double>(featureRanks.size()); for (FeatureRank fr : featureRanks) evalMap.put(fr.getFeatureName(), fr.getEvaluation()); return evalMap; }
From source file:org.apache.ctakes.ytex.umls.dao.UMLSDaoImpl.java
License:Apache License
private void updateNames(String queryName, List<String> subList, Map<String, String> names) { Query q = sessionFactory.getCurrentSession().getNamedQuery(queryName); q.setParameterList("cuis", subList); @SuppressWarnings("unchecked") List<Object[]> listCuiName = q.list(); for (Object[] cuiName : listCuiName) { names.put((String) cuiName[0], (String) cuiName[1]); }//from w w w . ja v a 2 s . c o m }
From source file:org.apache.ode.daohib.bpel.HibernateDao.java
License:Apache License
@SuppressWarnings("unchecked") protected void deleteByColumn(Class entity, String column, List<Long> values) { if (values != null && values.size() > 0) { final String delete = "delete from " + entity.getName() + " as e where e." + column + " in (:values)"; // some databases don't like long lists of values with IN operator // so we delete in batches. Oracle 9i, for instance, doesn't support // more than 1000 -- we opt to be conservative. final int batchSize = 100; int index = 0; while (index < values.size()) { List<Long> subList = values.subList(index, Math.min(index + batchSize, values.size())); Query query = getSession().createQuery(delete); query.setParameterList("values", subList); query.executeUpdate();/*w w w . ja v a2 s. c o m*/ index += batchSize; } } }
From source file:org.apache.ode.daohib.bpel.ProcessManagementDaoImpl.java
License:Apache License
public Map<InstanceSummaryKey, Long> countInstancesSummary(Set<String> pids) { Map<InstanceSummaryKey, Long> result = new HashMap<InstanceSummaryKey, Long>(); if (!pids.isEmpty()) { for (StatusKeys status : InstanceFilter.StatusKeys.values()) { Query query = getSession() .getNamedQuery(HProcessInstance.COUNT_INSTANCES_BY_PROCESSES_IDS_AND_STATES); query.setParameterList("states", new InstanceFilter("status=" + status.toString()).convertFilterState()); query.setParameterList("processIds", pids); for (Object o : query.list()) { Object[] row = (Object[]) o; InstanceSummaryKey key = new InstanceSummaryKey(row[0].toString(), status.toString()); result.put(key, (Long) row[1]); }/*from w w w. j av a2 s .c om*/ } } return result; }
From source file:org.apache.ode.daohib.bpel.ProcessManagementDaoImpl.java
License:Apache License
public Map<String, FailedSummaryValue> findFailedCountAndLastFailedDateForProcessIds(Set<String> pids) { Map<String, FailedSummaryValue> result = new HashMap<String, FailedSummaryValue>(); if (!pids.isEmpty()) { Query query = getSession() .getNamedQuery(HProcessInstance.COUNT_FAILED_INSTANCES_BY_PROCESSES_IDS_AND_STATES); query.setParameterList("processIds", pids); for (Object o : query.list()) { Object[] row = (Object[]) o; result.put(row[0].toString(), new FailedSummaryValue((Long) row[1], (Date) row[2])); }/*from www .j a va2 s . com*/ } return result; }
From source file:org.apache.shindig.social.opensocial.hibernate.services.ActivityServiceImpl.java
License:Apache License
public Future<Void> deleteActivities(UserId userId, GroupId groupId, String appId, Set<String> activityIds, SecurityToken token) throws ProtocolException { if (appId == null) { appId = token.getAppId();/* ww w . j a v a 2 s. c o m*/ } Session session = HibernateUtils.currentSession(); Transaction tx = session.beginTransaction(); Query query = session.createQuery( "select a from ActivityImpl a where a.userId = :userId and a.appId = :appId and a.id in (:activityIds)"); query.setParameter("userId", userId.getUserId(token)); query.setParameter("appId", appId); query.setParameterList("activityIds", activityIds); List<ActivityImpl> activities = (List<ActivityImpl>) query.list(); for (ActivityImpl activity : activities) { session.delete(activity); } tx.commit(); return ImmediateFuture.newInstance(null); }
From source file:org.apache.shindig.social.opensocial.hibernate.services.ActivityServiceImpl.java
License:Apache License
public Future<RestfulCollection<Activity>> getActivities(UserId userId, GroupId groupId, String appId, Set<String> fields, CollectionOptions options, Set<String> activityIds, SecurityToken token) throws ProtocolException { if (appId == null) { appId = token.getAppId();/*from ww w . j av a 2 s.co m*/ } Session session = HibernateUtils.currentSession(); Set<String> ids = getIdSet(userId, groupId, token); Query query = session.createQuery( "select a from ActivityImpl a where a.userId in (:ids) and a.appId = :appId and a.id in (:activityIds)"); query.setParameterList("ids", ids); query.setParameter("appId", appId); query.setParameterList("activityIds", activityIds); List<Activity> activities = (List<Activity>) query.list(); RestfulCollection<Activity> result = new RestfulCollection<Activity>(activities); return ImmediateFuture.newInstance(result); }
From source file:org.apache.shindig.social.opensocial.hibernate.services.ActivityServiceImpl.java
License:Apache License
public Future<RestfulCollection<Activity>> getActivities(Set<UserId> userIds, GroupId groupId, String appId, Set<String> fields, CollectionOptions options, SecurityToken token) throws ProtocolException { if (appId == null) { appId = token.getAppId();//from w w w . j a v a 2 s . c o m } Session session = HibernateUtils.currentSession(); Set<String> ids = new TreeSet<String>(); for (UserId userId : userIds) { ids.addAll(getIdSet(userId, groupId, token)); } Query query = session .createQuery("select a from ActivityImpl a where a.userId in (:ids) and a.appId = :appId"); query.setParameterList("ids", ids); query.setParameter("appId", appId); List<Activity> activities = (List<Activity>) query.list(); RestfulCollection<Activity> result = new RestfulCollection<Activity>(activities); return ImmediateFuture.newInstance(result); }
From source file:org.apache.shindig.social.opensocial.hibernate.services.AppDataServiceImpl.java
License:Apache License
public Future<DataCollection> getPersonData(Set<UserId> userIds, GroupId groupId, String appId, Set<String> fields, SecurityToken token) throws ProtocolException { if (appId == null) { appId = token.getAppId();//from w w w. j a v a 2 s.c o m } Set<String> ids = new TreeSet<String>(); for (UserId userId : userIds) { ids.addAll(getIdSet(userId, groupId, token)); } Session session = HibernateUtils.currentSession(); Query query = session.createQuery("select p from PersonImpl p where p.id in (:ids) order by p.id"); query.setParameterList("ids", ids); List<Person> people = (List<Person>) query.list(); query = session.createQuery( "select d from ApplicationDataMapImpl d where d.person in (:people) order by d.person.id"); query.setParameterList("people", people); List<ApplicationDataMapImpl> dataMapList = (List<ApplicationDataMapImpl>) query.list(); Map<String, Map<String, String>> entry = new HashMap<String, Map<String, String>>(); for (ApplicationDataMapImpl appData : dataMapList) { String personId = appData.getPerson().getId(); Map<String, String> dataMap = appData.getDataMap(); dataMap = filterMap(dataMap, fields); if (dataMap.size() > 0) { entry.put(personId, dataMap); } } return ImmediateFuture.newInstance(new DataCollection(entry)); }