List of usage examples for org.hibernate.criterion Projections projectionList
public static ProjectionList projectionList()
From source file:de.lemo.dms.connectors.moodle_2_7.ExtractAndMap.java
License:Open Source License
/** * Reads the Mining Database./*w ww. java2 s .c o m*/ * Initial informations needed to start the process of updating are collected here. * The Timestamp of the last run of the extractor is read from the config table * and the objects which might been needed to associate are read and saved here. * * @return The timestamp of the last run of the extractor. If this is the first run it will be set 0. **/ public long getMiningInitial() { final Session session = this.dbHandler.getMiningSession(); List<?> t; Long readingtimestamp; readingtimestamp = (Long) session .createQuery( "Select max(latestTimestamp) from Config where platform=" + this.connector.getPlatformId()) .uniqueResult(); if (readingtimestamp == null) { readingtimestamp = -1L; } // load objects which are already in Mining DB for associations Criteria criteria = session.createCriteria(Course.class, "obj"); criteria.addOrder(Property.forName("obj.id").asc()); t = criteria.list(); this.oldCourseMining = new HashMap<Long, Course>(); for (int i = 0; i < t.size(); i++) { this.oldCourseMining.put(((Course) (t.get(i))).getId(), (Course) t.get(i)); } logger.info("Loaded " + this.oldCourseMining.size() + " Course objects from the mining database."); criteria = session.createCriteria(User.class, "obj"); criteria.addOrder(Property.forName("obj.id").asc()); t = criteria.list(); this.oldUserMining = new HashMap<Long, User>(); for (int i = 0; i < t.size(); i++) { this.oldUserMining.put(((User) (t.get(i))).getId(), (User) t.get(i)); } logger.info("Loaded " + this.oldUserMining.size() + " User objects from the mining database."); criteria = session.createCriteria(LearningObj.class, "obj"); criteria.addOrder(Property.forName("obj.id").asc()); t = criteria.list(); this.oldLearningObjectMining = new HashMap<Long, LearningObj>(); for (int i = 0; i < t.size(); i++) { this.oldLearningObjectMining.put(((LearningObj) (t.get(i))).getId(), (LearningObj) t.get(i)); } logger.info( "Loaded " + this.oldLearningObjectMining.size() + " LearningObj objects from the mining database."); criteria = session.createCriteria(Attribute.class, "obj"); criteria.addOrder(Property.forName("obj.id").asc()); t = criteria.list(); this.oldAttributeMining = new HashMap<String, Attribute>(); for (int i = 0; i < t.size(); i++) { this.oldAttributeMining.put(((Attribute) (t.get(i))).getName(), (Attribute) t.get(i)); } logger.info("Loaded " + this.oldAttributeMining.size() + " Attribute objects from the mining database."); criteria = session.createCriteria(Role.class, "obj"); criteria.addOrder(Property.forName("obj.id").asc()); t = criteria.list(); this.oldRoleMining = new HashMap<Long, Role>(); for (int i = 0; i < t.size(); i++) { this.oldRoleMining.put(((Role) (t.get(i))).getId(), (Role) t.get(i)); } logger.info("Loaded " + this.oldRoleMining.size() + " Role objects from the mining database."); criteria = session.createCriteria(LearningType.class, "obj"); criteria.addOrder(Property.forName("obj.id").asc()); t = criteria.list(); this.oldLearningTypeMining = new HashMap<String, LearningType>(); for (int i = 0; i < t.size(); i++) { this.oldLearningTypeMining.put(((LearningType) (t.get(i))).getType(), (LearningType) t.get(i)); } logger.info( "Loaded " + this.oldLearningTypeMining.size() + " LearningType objects from the mining database."); criteria = session.createCriteria(CourseAttribute.class, "obj"); criteria.addOrder(Property.forName("obj.id").asc()); t = criteria.list(); this.oldCourseAttributeMining = new HashMap<Long, CourseAttribute>(); for (int i = 0; i < t.size(); i++) { this.oldCourseAttributeMining.put(((CourseAttribute) (t.get(i))).getId(), (CourseAttribute) t.get(i)); } logger.info("Loaded " + this.oldCourseAttributeMining.size() + " CourseAttribute objects from the mining database."); criteria = session.createCriteria(UserAttribute.class, "obj"); criteria.addOrder(Property.forName("obj.id").asc()); t = criteria.list(); this.oldUserAttributeMining = new HashMap<Long, UserAttribute>(); for (int i = 0; i < t.size(); i++) { this.oldUserAttributeMining.put(((UserAttribute) (t.get(i))).getId(), (UserAttribute) t.get(i)); } logger.info("Loaded " + this.oldUserAttributeMining.size() + " UserAttribute objects from the mining database."); criteria = session.createCriteria(LearningAttribute.class, "obj"); criteria.addOrder(Property.forName("obj.id").asc()); t = criteria.list(); this.oldLearningAttributeMining = new HashMap<Long, LearningAttribute>(); for (int i = 0; i < t.size(); i++) { this.oldLearningAttributeMining.put(((LearningAttribute) (t.get(i))).getId(), (LearningAttribute) t.get(i)); } logger.info("Loaded " + this.oldUserAttributeMining.size() + " LearningAttribute objects from the mining database."); criteria = session.createCriteria(CourseLearning.class, "obj"); criteria.addOrder(Property.forName("obj.id").asc()); t = criteria.list(); this.oldCourseLearningObjectMining = new HashMap<Long, CourseLearning>(); for (int i = 0; i < t.size(); i++) { this.oldCourseLearningObjectMining.put(((CourseLearning) (t.get(i))).getId(), (CourseLearning) t.get(i)); } logger.info("Loaded " + this.oldCourseLearningObjectMining.size() + " CourseResource objects from the mining database."); criteria = session.createCriteria(UserAssessment.class, "obj"); criteria.addOrder(Property.forName("obj.id").asc()); t = criteria.list(); this.oldUserAssessmentMining = new HashMap<Long, UserAssessment>(); for (int i = 0; i < t.size(); i++) { this.oldUserAssessmentMining.put(((UserAssessment) (t.get(i))).getId(), (UserAssessment) t.get(i)); } logger.info("Loaded " + this.oldUserAssessmentMining.size() + " UserAssessment objects from the mining database."); criteria = session.createCriteria(CourseUser.class, "obj"); criteria.addOrder(Property.forName("obj.id").asc()); t = criteria.list(); this.oldCourseUserMining = new HashMap<Long, CourseUser>(); for (int i = 0; i < t.size(); i++) { this.oldCourseUserMining.put(((CourseUser) (t.get(i))).getId(), (CourseUser) t.get(i)); } logger.info("Loaded " + this.oldCourseUserMining.size() + " CourseUser objects from the mining database."); criteria = session.createCriteria(AccessLog.class); ProjectionList pl = Projections.projectionList(); pl.add(Projections.max("id")); criteria.setProjection(pl); this.accessLogMax = (Long) criteria.list().get(0); if (this.accessLogMax == null) { this.accessLogMax = 0L; } criteria = session.createCriteria(CollaborationLog.class); criteria.setProjection(pl); this.collaborationLogMax = (Long) criteria.list().get(0); if (this.collaborationLogMax == null) { this.collaborationLogMax = 0L; } criteria = session.createCriteria(AssessmentLog.class); criteria.setProjection(pl); this.assessmentLogMax = (Long) criteria.list().get(0); if (this.assessmentLogMax == null) { this.assessmentLogMax = 0L; } criteria = session.createCriteria(LearningType.class); criteria.setProjection(pl); this.learningObjectTypeMax = (Long) criteria.list().get(0); if (this.learningObjectTypeMax == null) { this.learningObjectTypeMax = 0L; } criteria = session.createCriteria(Attribute.class); criteria.setProjection(pl); this.attributeIdMax = (Long) criteria.list().get(0); if (this.attributeIdMax == null) { this.attributeIdMax = 0L; } criteria = session.createCriteria(CourseAttribute.class); criteria.setProjection(pl); this.courseAttributeIdMax = (Long) criteria.list().get(0); if (this.courseAttributeIdMax == null) { this.courseAttributeIdMax = 0L; } criteria = session.createCriteria(UserAttribute.class); criteria.setProjection(pl); this.userAttributeIdMax = (Long) criteria.list().get(0); if (this.userAttributeIdMax == null) { this.userAttributeIdMax = 0L; } criteria = session.createCriteria(LearningAttribute.class); criteria.setProjection(pl); this.learningAttributeIdMax = (Long) criteria.list().get(0); if (this.learningAttributeIdMax == null) { this.learningAttributeIdMax = 0L; } //this.dbHandler.closeSession(session); return readingtimestamp; }
From source file:de.powerstaff.business.dao.hibernate.PersonDAOHibernateImpl.java
License:Open Source License
protected Collection<GenericSearchResult> performSearchByContact(final String aContact, final ContactType aContactType, final String[] aDisplayProperties, final String[] aOrderByProperties, final int aMax) { return (Collection<GenericSearchResult>) getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session aSession) throws SQLException { Criteria theCriteria = aSession.createCriteria(getEntityClass()); ProjectionList theList = Projections.projectionList(); theList.add(Projections.property("id")); for (String theProperty : aDisplayProperties) { theList.add(Projections.property(theProperty)); }//from w w w .j a va 2 s. com theCriteria.setProjection(theList); for (String theProperty : aOrderByProperties) { theCriteria.addOrder(Order.asc(theProperty)); } Criteria theContacts = theCriteria.createCriteria("contacts"); theContacts.add(Restrictions.eq("type", aContactType)); theContacts.add(Restrictions.ilike("value", "%" + aContact + "%")); Collection<GenericSearchResult> theResult = new ArrayList<GenericSearchResult>(); theCriteria.setMaxResults(aMax); for (Iterator it = theCriteria.list().iterator(); it.hasNext();) { Object[] theRow = (Object[]) it.next(); GenericSearchResult theRowObject = new GenericSearchResult(); theRowObject.put(GenericSearchResult.OBJECT_ID_KEY, theRow[0]); for (int i = 0; i < aDisplayProperties.length; i++) { theRowObject.put(aDisplayProperties[i], theRow[i + 1]); } theResult.add(theRowObject); } return theResult; } }); }
From source file:de.powerstaff.business.dao.hibernate.StatistikDAOHibernateImpl.java
License:Open Source License
@Override public List<KontakthistorieEntry> kontakthistorie(final Date aDatumVon, final Date aDatumBis, final User aBenutzer) { return (List<KontakthistorieEntry>) getHibernateTemplate().execute(new HibernateCallback() { @Override//from www. jav a2 s . c om public Object doInHibernate(Session aSession) throws SQLException { List<KontakthistorieEntry> theResult = new ArrayList<KontakthistorieEntry>(); Conjunction theRestrictions = Restrictions.conjunction(); if (aDatumVon != null) { theRestrictions.add(Restrictions.ge("h.creationDate", aDatumVon)); } if (aDatumBis != null) { theRestrictions.add(Restrictions.le("h.creationDate", aDatumBis)); } if (aBenutzer != null) { theRestrictions.add(Restrictions.eq("h.creationUserID", aBenutzer.getUsername())); } // Freiberufler Criteria theCriteria = aSession.createCriteria(Freelancer.class, "p"); theCriteria.createCriteria("history", "h"); theCriteria.add(theRestrictions); ProjectionList theProjections = Projections.projectionList(); theProjections.add(Projections.property("p.name1")); theProjections.add(Projections.property("p.name2")); theProjections.add(Projections.property("p.code")); theProjections.add(Projections.property("h.creationDate")); theProjections.add(Projections.property("h.creationUserID")); theProjections.add(Projections.property("h.type")); theProjections.add(Projections.property("h.description")); theCriteria.setProjection(theProjections); for (Object theResultObject : theCriteria.list()) { Object[] theResultArray = (Object[]) theResultObject; KontakthistorieEntry theEntry = new KontakthistorieEntry(); theEntry.setName1((String) theResultArray[0]); theEntry.setName2((String) theResultArray[1]); theEntry.setCode((String) theResultArray[2]); Timestamp theTimestamp = (Timestamp) theResultArray[3]; theEntry.setDatum(new Date(theTimestamp.getTime())); theEntry.setUserid((String) theResultArray[4]); theEntry.setType((HistoryType) theResultArray[5]); theEntry.setDescription((String) theResultArray[6]); theResult.add(theEntry); } // Partner theCriteria = aSession.createCriteria(Partner.class, "p"); theCriteria.createCriteria("history", "h"); theCriteria.add(theRestrictions); theProjections = Projections.projectionList(); theProjections.add(Projections.property("p.name1")); theProjections.add(Projections.property("p.name2")); theProjections.add(Projections.property("h.creationDate")); theProjections.add(Projections.property("h.creationUserID")); theProjections.add(Projections.property("h.type")); theProjections.add(Projections.property("h.description")); theCriteria.setProjection(theProjections); for (Object theResultObject : theCriteria.list()) { Object[] theResultArray = (Object[]) theResultObject; KontakthistorieEntry theEntry = new KontakthistorieEntry(); theEntry.setName1((String) theResultArray[0]); theEntry.setName2((String) theResultArray[1]); Timestamp theTimestamp = (Timestamp) theResultArray[2]; theEntry.setDatum(new Date(theTimestamp.getTime())); theEntry.setUserid((String) theResultArray[3]); theEntry.setType((HistoryType) theResultArray[4]); theEntry.setDescription((String) theResultArray[5]); theResult.add(theEntry); } // Kunden theCriteria = aSession.createCriteria(Customer.class, "p"); theCriteria.createCriteria("history", "h"); theCriteria.add(theRestrictions); theProjections = Projections.projectionList(); theProjections.add(Projections.property("p.name1")); theProjections.add(Projections.property("p.name2")); theProjections.add(Projections.property("h.creationDate")); theProjections.add(Projections.property("h.creationUserID")); theProjections.add(Projections.property("h.type")); theProjections.add(Projections.property("h.description")); theCriteria.setProjection(theProjections); for (Object theResultObject : theCriteria.list()) { Object[] theResultArray = (Object[]) theResultObject; KontakthistorieEntry theEntry = new KontakthistorieEntry(); theEntry.setName1((String) theResultArray[0]); theEntry.setName2((String) theResultArray[1]); Timestamp theTimestamp = (Timestamp) theResultArray[2]; theEntry.setDatum(new Date(theTimestamp.getTime())); theEntry.setUserid((String) theResultArray[3]); theEntry.setType((HistoryType) theResultArray[4]); theEntry.setDescription((String) theResultArray[5]); theResult.add(theEntry); } Collections.sort(theResult, new ReverseComparator(new BeanComparator("datum"))); return theResult; } }); }
From source file:de.sub.goobi.forms.ProjekteForm.java
License:Open Source License
/** * generates values for count of volumes and images for statistics. *//*from w w w . ja va2 s.c o m*/ @SuppressWarnings("rawtypes") public void GenerateValuesForStatistics() { Criteria crit = Helper.getHibernateSession().createCriteria(Process.class) .add(Restrictions.eq("projekt", this.myProjekt)); ProjectionList pl = Projections.projectionList(); pl.add(Projections.sum("sortHelperImages")); pl.add(Projections.count("sortHelperImages")); crit.setProjection(pl); List list = crit.list(); Long images = 0l; Long volumes = 0l; for (Object obj : list) { Object[] row = (Object[]) obj; images = (Long) row[0]; volumes = (Long) row[1]; } this.myProjekt.setNumberOfPages(images.intValue()); this.myProjekt.setNumberOfVolumes(volumes.intValue()); }
From source file:de.sub.goobi.helper.ProjectHelper.java
License:Open Source License
/** * static to reduce load//from w w w . j av a2 s.co m * * @param project * object * @return a GoobiCollection of the following structure: GoobiCollection 1-n * representing the steps each step has the following properties @ * stepTitle, stepOrder, * stepCount,stepImageCount,totalProcessCount,totalImageCount which * can get extracted by the IGoobiCollection Interface using the * getItem(<name>) method standard workflow of the project * according to the definition that only steps shared by all * processes are returned. The workflow order is returned according * to the average order return by a grouping by step title consider * workflow structure to be a prototype, it would probably make * things easier, to either assemble the underlying construction in * separate classes or to create a new class with these properties */ @SuppressWarnings("unchecked") public static synchronized List<StepInformation> getProjectWorkFlowOverview(Project project) { Long totalNumberOfProc = 0l; Long totalNumberOfImages = 0l; Session session = Helper.getHibernateSession(); Criteria critTotals = session.createCriteria(Process.class, "proc"); critTotals.add(Restrictions.eq("proc.template", Boolean.FALSE)); critTotals.add(Restrictions.eq("proc.project", project)); ProjectionList proList = Projections.projectionList(); proList.add(Projections.count("proc.id")); proList.add(Projections.sum("proc.sortHelperImages")); critTotals.setProjection(proList); List<Object> list = critTotals.list(); for (Object obj : list) { Object[] row = (Object[]) obj; totalNumberOfProc = (Long) row[FieldList.totalProcessCount.fieldLocation]; totalNumberOfImages = (Long) row[FieldList.totalImageCount.fieldLocation]; ; } proList = null; list = null; Criteria critSteps = session.createCriteria(Task.class); critSteps.createCriteria("process", "proc"); critSteps.addOrder(Order.asc("ordering")); critSteps.add(Restrictions.eq("proc.template", Boolean.FALSE)); critSteps.add(Restrictions.eq("proc.project", project)); proList = Projections.projectionList(); proList.add(Projections.groupProperty(("title"))); proList.add(Projections.count("id")); proList.add(Projections.avg("ordering")); critSteps.setProjection(proList); // now we have to discriminate the hits where the max number of hits // doesn't reach numberOfProcs // and extract a workflow, which is the workflow common for all // processes according to its titel // the position will be calculated by the average of 'reihenfolge' of // steps list = critSteps.list(); String title; Double averageStepOrder; Long numberOfSteps; Long numberOfImages; List<StepInformation> workFlow = new ArrayList<>(); for (Object obj : list) { Object[] row = (Object[]) obj; title = (String) (row[FieldList.stepName.fieldLocation]); numberOfSteps = (Long) (row[FieldList.stepCount.fieldLocation]); averageStepOrder = (Double) (row[FieldList.stepOrder.fieldLocation]); // in this step we only take the steps which are present in each of // the workflows if (numberOfSteps.equals(totalNumberOfProc)) { StepInformation newStep = new StepInformation(title, averageStepOrder); newStep.setNumberOfTotalImages(totalNumberOfImages.intValue()); newStep.setNumberOfTotalSteps(totalNumberOfProc.intValue()); workFlow.add(newStep); } } Criteria critStepDone = session.createCriteria(Task.class, "step"); critStepDone.createCriteria("process", "proc"); critStepDone.add(Restrictions.eq("step.processingStatus", TaskStatus.DONE.getValue())); critStepDone.add(Restrictions.eq("proc.template", Boolean.FALSE)); critStepDone.add(Restrictions.eq("proc.project", project)); ProjectionList proCount = Projections.projectionList(); proCount.add(Projections.groupProperty(("step.title"))); proCount.add(Projections.count("proc.id")); proCount.add(Projections.sum("proc.sortHelperImages")); critStepDone.setProjection(proCount); list = critStepDone.list(); for (Object obj : list) { Object[] row = (Object[]) obj; title = (String) (row[FieldList.stepName.fieldLocation]); numberOfSteps = (Long) (row[FieldList.stepCount.fieldLocation]); numberOfImages = (Long) (row[FieldList.imageCount.fieldLocation]); // getting from the workflow collection the collection which // represents step <title> // we only created one for each step holding the counts of processes for (StepInformation currentStep : workFlow) { if (currentStep.getTitle().equals(title)) { currentStep.setNumberOfStepsDone(numberOfSteps.intValue()); currentStep.setNumberOfImagesDone(numberOfImages.intValue()); } } } Comparator<StepInformation> comp = new compareWorkflowSteps(); Collections.sort(workFlow, comp); return workFlow; }
From source file:de.tudarmstadt.ukp.lmf.api.UbyStatistics.java
License:Apache License
/** * Return a {@link Set} of {@link String} instances consisting of <code>lemma+"_"+part-of-speech</code>, * filtered by given {@link Lexicon} name.<br> * The lemma is obtained from the written form of the first {@link FormRepresentation} of the {@link Lemma} * instance./*from w ww . j a v a 2 s . c o m*/ * @param lexiconName * name of the lexicon which lemmas should be used * * @return a set of strings containing lemma and part-of-speech of the specified lexicon.<br> * This method returns an empty set if the lexicon with the specified name does no exist. * * @see Lemma#getFormRepresentations() * @see FormRepresentation#getWrittenForm() * @see EPartOfSpeech */ public Set<String> getLemmaPosPerLexicon(String lexiconName) { Criteria criteria = session.createCriteria(Lexicon.class, "l"); criteria = criteria.createCriteria("lexicalEntries", "e"); if (lexiconName != null) { criteria = criteria.add(Restrictions.eq("l.name", lexiconName)); } criteria = criteria.createCriteria("lemma").createCriteria("formRepresentations", "f") .setProjection(Projections.projectionList().add(Property.forName("f.writtenForm")) .add(Property.forName("e.partOfSpeech"))); ScrollableResults res = criteria.scroll(); ArrayList<String> out = new ArrayList<String>(); while (res.next()) { Object[] r = res.get(); if (r[1] != null) { // some resources do not have POS out.add((String) r[0] + "_" + ((EPartOfSpeech) r[1]).toString()); } else { out.add((String) r[0] + "_null"); } } HashSet<String> out2 = new HashSet<String>(out); return out2; }
From source file:de.tudarmstadt.ukp.lmf.api.UbyStatistics.java
License:Apache License
/** * Return a {@link Set} of {@link String} instances consisting of <code>lemma+"_"+part-of-speech</code>, * filtered by given {@link Lexicon} name, part-of-speech prefix and a language identifier.<br> * The lemma is obtained from the written form of the first {@link FormRepresentation} of the {@link Lemma} * instance./*from w w w. j a v a 2 s . com*/ * * @param lexiconName * name of the lexicon which lemmas should be used * * @param prefix the part-of-speech prefix used when filtering {@link LexicalEntry} instances * * @param lang the language identifier used when filtering lexical entries * * @return a set of strings containing lemma and part-of-speech of the specified lexicon.<br> * * This method returns an empty set if the lexicon with the specified name does no exist or * the lexicon does not contain any lexical entries with specified part-of-speech prefix and language * identifier. * * @see Lemma#getFormRepresentations() * @see FormRepresentation#getWrittenForm() * @see EPartOfSpeech * @see ELanguageIdentifier */ public Set<String> getLemmaPosPerLexiconAndPosPrefixAndLanguage(String lexiconName, String prefix, String lang) { Criteria criteria = session.createCriteria(Lexicon.class, "l"); criteria = criteria.createCriteria("lexicalEntries", "e"); if (lexiconName != null) { criteria = criteria.add(Restrictions.eq("l.name", lexiconName)); } if (lang != null) { criteria = criteria.add(Restrictions.eq("l.languageIdentifier", lang)); } if (prefix != null) { criteria = criteria.add(Restrictions.sqlRestriction("partOfSpeech like '" + prefix + "'")); } criteria = criteria.createCriteria("lemma").createCriteria("formRepresentations", "f") .setProjection(Projections.projectionList().add(Property.forName("f.writtenForm")) .add(Property.forName("e.partOfSpeech"))); ScrollableResults res = criteria.scroll(); ArrayList<String> out = new ArrayList<String>(); while (res.next()) { Object[] r = res.get(); if (r[1] != null) { out.add((String) r[0] + "_" + ((EPartOfSpeech) r[1]).toString()); } else { out.add((String) r[0] + "_null"); } } HashSet<String> out2 = new HashSet<String>(out); return out2; }
From source file:edu.monash.merc.dao.DSVersionDAO.java
License:Open Source License
/** * {@inheritDoc}// w w w . j a va 2 s . c o m */ @SuppressWarnings("unchecked") public List<DBVersionBean> getLatestDBSVersionByChromosome(ChromType chromType) { Criteria dsvCriteria = this.session().createCriteria(this.persistClass); dsvCriteria.add(Restrictions.eq("chromosome", chromType.chm())); dsvCriteria.setProjection( Projections.projectionList().add(Projections.groupProperty("dbSource").as("dbSource")) .add(Projections.max("id").as("id")).add(Projections.max("createdTime").as("createdTime")) .add(Projections.max("versionNo").as("versionNo"))); dsvCriteria.addOrder(Order.asc("dbSource")); return dsvCriteria.setResultTransformer(Transformers.aliasToBean(DBVersionBean.class)).list(); }
From source file:edu.monash.merc.dao.TPBVersionDAO.java
License:Open Source License
/** * {@inheritDoc}/*from ww w .j a v a 2 s .com*/ */ @SuppressWarnings("unchecked") public List<MaxDsTPBVersion> getAllChromosomeTPBVersionByMaxCombinatedDs() { Criteria tpbVCriteria = this.session().createCriteria(this.persistClass); tpbVCriteria.setProjection( Projections.projectionList().add(Projections.groupProperty("chromosome").as("chromosome")) .add(Projections.max("id").as("id")).add(Projections.max("trackToken").as("trackToken")) .add(Projections.max("versionNo").as("versionNo"))); List<MaxDsTPBVersion> maxDsTPBVersions = tpbVCriteria .setResultTransformer(Transformers.aliasToBean(MaxDsTPBVersion.class)).list(); // System.out.println("======= max ds tpb versions size: " + maxDsTPBVersions.size()); // for(MaxDsTPBVersion maxDsTPBVersion : maxDsTPBVersions){ // System.out.println("========= > " +maxDsTPBVersion.getId() + " -- " + maxDsTPBVersion.getChromosome() + " -- " + maxDsTPBVersion.getTrackToken() + " -- " + maxDsTPBVersion.getVersionNo()); // } return maxDsTPBVersions; }
From source file:edu.northwestern.bioinformatics.studycalendar.dao.ActivityDao.java
License:BSD License
@SuppressWarnings({ "unchecked" }) public Long getCount() { return (Long) CollectionUtils.firstElement(getSession().createCriteria(Activity.class) .setProjection(Projections.projectionList().add(Projections.rowCount())).list()); }