List of usage examples for org.hibernate Criteria setResultTransformer
public Criteria setResultTransformer(ResultTransformer resultTransformer);
From source file:com.scopix.periscope.extractionplanmanagement.dao.ExtractionPlanCustomizingDAOImpl.java
License:Open Source License
@Override public List<Indicator> getIndicatorNameList(AreaType areaType, Product product) { List<Indicator> indicators = null; Session session = this.getSession(); try {//from w ww . j a v a2s . c o m Criteria criteria = session.createCriteria(Indicator.class); criteria.addOrder(Order.asc("name")); if (areaType != null) { criteria.add(Restrictions.eq("areaType.id", areaType.getId())); } if (product != null) { criteria.add(Restrictions.eq("product.id", product.getId())); } indicators = criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list(); } catch (HibernateException e) { log.error(e, e); } finally { this.releaseSession(session); } return indicators; }
From source file:com.scopix.periscope.extractionplanmanagement.dao.ExtractionPlanCustomizingDAOImpl.java
License:Open Source License
/** * retorna un ExtractionPlanCustomizing dado SituationTemplate, MetricTemplate, Store, EvidenceProvider Esto se genera por * cambio de generacion y extraccion del EPC *///w w w.j ava 2 s .c o m @Override public ExtractionPlanCustomizing getWizardCustomizing(ExtractionPlanCustomizing wizardCustomizing) { ExtractionPlanCustomizing extractionPlanCustomizing = null; Session session = this.getSession(); try { Criteria criteria = session.createCriteria(ExtractionPlanCustomizing.class); //criteria.addOrder(Order.asc("evaluationOrder")); if (wizardCustomizing != null) { if (wizardCustomizing.getSituationTemplate() != null && wizardCustomizing.getSituationTemplate().getId() != null && wizardCustomizing.getSituationTemplate().getId() > 0) { criteria.add(Restrictions.eq("situationTemplate.id", wizardCustomizing.getSituationTemplate().getId())); } //si existen metricas definidas if (!wizardCustomizing.getExtractionPlanMetrics().isEmpty()) { MetricTemplate metricTemplate = wizardCustomizing.getExtractionPlanMetrics().get(0) .getMetricTemplate(); if (metricTemplate != null && metricTemplate.getId() != null && metricTemplate.getId() > 0) { criteria.add(Restrictions.eq("metricTemplate.id", metricTemplate.getId())); } } if (wizardCustomizing.getStore() != null && wizardCustomizing.getStore().getId() != null && wizardCustomizing.getStore().getId() > 0) { criteria.add(Restrictions.eq("store.id", wizardCustomizing.getStore().getId())); } } criteria.add(Restrictions.or(Restrictions.eq("active", true), Restrictions.isNull("active"))); List<ExtractionPlanCustomizing> l = criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list(); if (l.size() > 1) { for (ExtractionPlanCustomizing epc : l) { if (epc.isActive() == null) { extractionPlanCustomizing = epc; break; } } log.debug("lista de epc > 1 " + l.size()); //todo revisar que paso } else if (l.size() == 1) { extractionPlanCustomizing = l.get(0); } } catch (HibernateException e) { log.error(e, e); } finally { this.releaseSession(session); } return extractionPlanCustomizing; }
From source file:com.scopix.periscope.extractionplanmanagement.EServerDAO.java
License:Open Source License
public ExtractionPlan getExtractionPlanForADate(Date date) { ExtractionPlan extractionPlan = null; Criteria criteria = this.getSession().createCriteria(ExtractionPlan.class); criteria.addOrder(Order.asc("expirationDate")); criteria.add(Restrictions.isNotNull("expirationDate")); criteria.add(Restrictions.gt("expirationDate", date)); List<ExtractionPlan> eps = criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list(); if (eps != null && !eps.isEmpty()) { extractionPlan = (ExtractionPlan) eps.get(0); }//w w w .ja v a 2 s . c o m return extractionPlan; }
From source file:com.scopix.periscope.extractionplanmanagement.EServerDAO.java
License:Open Source License
public List<ExtractionPlan> getExtractionPlanListForADate(Date date, String storeName) { Criteria criteria = this.getSession().createCriteria(ExtractionPlan.class); criteria.addOrder(Order.asc("expirationDate")); criteria.add(/* ww w. j av a2 s . c o m*/ Restrictions.or(Restrictions.isNull("expirationDate"), Restrictions.gt("expirationDate", date))); criteria.add(Restrictions.eq("storeName", storeName)); List<ExtractionPlan> eps = criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list(); return eps; }
From source file:com.scopix.periscope.queuemanagement.dao.QueueManagementHibernateDAO.java
License:Open Source License
/** * * @param pendingEvaluationId id de PendingEvaluation para filtro * @return List<MetricTemplate> lista de Metric Template asociados a un pendingEvaluation * @throws PeriscopeException Excepcion en caso de Error *//* www . j av a 2 s . c o m*/ public List<MetricTemplate> getMetricTemplateForAPendingEvaluation(Integer pendingEvaluationId) throws ScopixException { log.info("start"); List<MetricTemplate> metricTemplates = null; try { Criteria criteria = this.getSession().createCriteria(MetricTemplate.class).createCriteria("metrics") .createCriteria("situation").createCriteria("observedSituations"); criteria.createCriteria("pendingEvaluation").add(Restrictions.eq("id", pendingEvaluationId)); metricTemplates = criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list(); } catch (Exception e) { log.error("Error " + e, e); //"periscopeexception.list.error", new String[]{ throw new ScopixException("label.metricTemplateForAPendingEvaluation"); } log.info("end, result = " + metricTemplates); return metricTemplates; }
From source file:com.scopix.periscope.subscription.dao.SubscriptionDAOImpl.java
License:Open Source License
@Override public List<Subscription> getAllByUserNameAndCorporateIdAsc() { log.info("executing getAllByUserNameAndCorporateIdAsc()"); List<Subscription> list; Criteria criteria = this.getSession().createCriteria(Subscription.class); criteria.addOrder(Order.asc("userName")); criteria.createAlias("operatorQueuePriority", "oqp"); criteria.addOrder(Order.asc("oqp.priority")); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); list = criteria.list();//from w w w . ja va 2s . com log.info("end()"); return list; }
From source file:com.senacor.core.manager.BaseManagerImpl.java
License:Apache License
public List<T> find(final T t) { Session session = getSession();//ww w. ja va2s . c o m Criteria criteria = session.createCriteria(boClass); criteria.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY); PropertyDescriptor[] descriptors = BeanUtils.getPropertyDescriptors(boClass); BeanWrapper beanWrapper = new BeanWrapperImpl(t); for (PropertyDescriptor descriptor : descriptors) { if (!descriptor.getName().equals("class") && !descriptor.getName().equals("id")) { Object value = beanWrapper.getPropertyValue(descriptor.getName()); if (value != null) { criteria.add(Restrictions.eq(descriptor.getName(), value)); } } } criteria.addOrder(Order.asc("id")); return criteria.list(); }
From source file:com.square.core.dao.implementations.DepartementDaoImplementation.java
License:Open Source License
@SuppressWarnings("unchecked") @Override/*from w ww . j a v a 2 s .c o m*/ public List<Departement> rechercherDepartementParCriteres(DimensionCritereRechercheDepartementDto criteres) { if (criteres.getDimensionCriteres() == null) { criteres.setDimensionCriteres(new DimensionCriteresRechercheDto()); } final Criteria criteria = createCriteria(Departement.class); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); // Critre sur l'identifiant if (criteres.getDimensionCriteres().getId() != null) { criteria.add(Restrictions.eq("id", criteres.getDimensionCriteres().getId())); } // Critre sur le libelle if (criteres.getDimensionCriteres().getLibelle() != null && !criteres.getDimensionCriteres().getLibelle().equals("")) { criteria.add(Restrictions.ilike("libelle", criteres.getDimensionCriteres().getLibelle().toLowerCase() + "%")); } // Critre sur la visibilit if (criteres.getDimensionCriteres().getVisible() != null) { criteria.add(Restrictions.eq("visible", criteres.getDimensionCriteres().getVisible())); } Criteria commune = null; // Critre sur la commune du departement. if (criteres.getIdCommune() != null) { commune = criteria.createAlias("communes", "commune"); commune.add(Restrictions.eq("commune.id", criteres.getIdCommune())); } if (criteres.getIdCodePostal() != null) { if (commune == null) { commune = criteria.createAlias("communes", "commune"); } criteria.createAlias("commune.codesPostaux", "codes") .add(Restrictions.eq("codes.codePostal.id", criteres.getIdCodePostal())); } // Maxresults if (criteres.getDimensionCriteres().getMaxResults() != null) { criteria.setFirstResult(0); criteria.setMaxResults(criteres.getDimensionCriteres().getMaxResults()); } // Ordonner les lments criteria.addOrder(Order.asc("ordre")); criteria.addOrder(Order.asc("libelle")); return criteria.list(); }
From source file:com.technologicaloddity.saha.dao.MappedModelDao.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<T> findAll() { Session session = getCurrentSession(); Criteria criteria = session.createCriteria(getActualClass()); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); return criteria.list(); }
From source file:com.technologicaloddity.saha.dao.MetadataDao.java
License:Creative Commons License
public Metadata getNameMetadata() { Session session = getCurrentSession(); Criteria criteria = session.createCriteria(getActualClass()); criteria.add(Restrictions.eq("metakey", "name")); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); criteria.setMaxResults(1);// ww w .j a va 2 s .co m Metadata result = (Metadata) criteria.uniqueResult(); if (result == null) { result = new Metadata(); result.setMetakey("name"); result.setMetavalue(null); } return result; }