List of usage examples for org.hibernate.criterion ProjectionList add
public ProjectionList add(Projection projection)
From source file:com.painiu.core.dao.hibernate.PhotoDAOHibernate.java
License:Open Source License
static Criteria buildPhotoCriteria(final Session session, User user, String[] tags, boolean taggedAll, String text, Relation relation, boolean count) { Criteria criteria = session.createCriteria(Photo.class); if (user != null) { criteria.add(Restrictions.eq("user", user)); if (relation != null) { criteria.add(/*w w w.j a v a 2 s. c o m*/ Restrictions.sqlRestriction(" {alias}.privacy & ? > 0", relation, UserTypes.relation())); } } else { criteria.add( Restrictions.sqlRestriction(" {alias}.privacy & ? > 0", Relation.NONE, UserTypes.relation())); criteria.setFetchMode("user", FetchMode.JOIN); } //if (user == null && group == null) { if (user == null) { Disjunction disjState = Restrictions.disjunction(); disjState.add(Restrictions.eq("state", Photo.State.USER_POPULAR)); disjState.add(Restrictions.eq("state", Photo.State.USER_COMMENDATORY)); disjState.add(Restrictions.eq("state", Photo.State.USER_SENIOR)); criteria.add(disjState); } //if (album != null) { // criteria.createAlias("albumPhotos", "ap"); // criteria.add( Restrictions.eq("ap.album", album) ); //} //if (group != null) { // criteria.createAlias("groupPhotos", "gp"); // criteria.add( Restrictions.eq("gp.group", group) ); //} if ((tags != null && tags.length > 0) || text != null) { Criteria subCriteria = criteria.createCriteria("photoTags", "tags"); if (tags != null && tags.length > 0) { if (taggedAll) { Conjunction conj = Restrictions.conjunction(); for (int i = 0; i < tags.length; i++) { conj.add(Restrictions.eq("tagName", tags[i])); } subCriteria.add(conj); } else { Disjunction disj = Restrictions.disjunction(); for (int i = 0; i < tags.length; i++) { disj.add(Restrictions.eq("tagName", tags[i])); } subCriteria.add(disj); } } if (text != null) { Disjunction disj = Restrictions.disjunction(); disj.add(Restrictions.like("title", text, MatchMode.ANYWHERE)); disj.add(Restrictions.like("description", text, MatchMode.ANYWHERE)); disj.add(Restrictions.eq("tags.tagName", text)); criteria.add(disj); } } // TODO order parameters if (!count) { /*if (album != null) { criteria.addOrder(Order.asc("ap.position")); } else*/ /*if (group != null) { criteria.addOrder(Order.asc("gp.position")); } else {*/ criteria.addOrder(Order.desc("timestamp")); //} } // distinct ? if ((tags != null && tags.length > 1) || text != null) { ProjectionList proj = Projections.projectionList(); proj.add(Projections.property("id")).add(Projections.property("title")) .add(Projections.property("width")).add(Projections.property("height")) .add(Projections.property("address.host")).add(Projections.property("address.dir")) .add(Projections.property("address.filename")).add(Projections.property("address.secret")) .add(Projections.property("address.username")).add(Projections.property("address.fileKey")); if (user == null) { criteria.createAlias("user", "user"); proj.add(Projections.property("user.id")).add(Projections.property("user.username")) .add(Projections.property("user.nickname")).add(Projections.property("user.buddyIcon.host")) .add(Projections.property("user.buddyIcon.dir")) .add(Projections.property("user.buddyIcon.filename")) .add(Projections.property("user.buddyIcon.username")) .add(Projections.property("user.buddyIcon.fileKey")); } criteria.setProjection(Projections.distinct(proj)); criteria.setResultTransformer(new PhotoBeanResultTransformer()); } return criteria; }
From source file:com.photon.phresco.eshop.service.EShopService.java
License:Apache License
public Review getReviews(final int productId) throws EShopException { @SuppressWarnings("unchecked") Review review = (Review) template.execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Review review = new Review(); review.setProductId(productId); review.setUserId(1);// w ww. j av a 2s . c o m List<KeyValue> ratings = new ArrayList<KeyValue>(5); Rating rating = new Rating(); int total = 0; for (int i = 1; i <= 5; i++) { List<Integer> count = session.createCriteria(ReviewHBM.class) .setProjection(Projections.rowCount()).add(Restrictions.eq("ratings", i)) .add(Restrictions.eq("productId", productId)).list(); System.out.println("count = " + count); int totalRating = (int) count.get(0); total += totalRating; System.out.println("Total Rating = " + totalRating); // reviewHBM.setTotalRating(totalRating); KeyValue keyvalue = new KeyValue(i, totalRating); ratings.add(keyvalue); rating.setRating(ratings); // reviews.add(reviewHBM); } Criteria crit = session.createCriteria(ReviewHBM.class) .add(Restrictions.eq("productId", productId)); ProjectionList p1 = Projections.projectionList(); p1.add(Projections.property("comment")); p1.add(Projections.property("ratings")); p1.add(Projections.property("commentDate")); p1.add(Projections.property("userId")); crit.setProjection(p1); List<Comment> list = crit.list(); Iterator iter = list.iterator(); List<Comment> comments = new ArrayList<Comment>(); while (iter.hasNext()) { Object[] obj = (Object[]) iter.next(); Comment comment = null; for (int i = 0; i < obj.length; i++) { comment = new Comment(); comment.setComment(obj[0].toString()); comment.setRatings((Integer) obj[1]); java.sql.Date sqlDate = (java.sql.Date) obj[2]; java.util.Date utilDate = new java.util.Date(sqlDate.getTime()); comment.setCommentDate(utilDate); comment.setUserid((Integer) obj[3]); comments.add(comment); Criteria criteria = session.createCriteria(UserHBM.class) .add(Restrictions.eq("userId", (Integer) obj[3])); ProjectionList p2 = Projections.projectionList(); p2.add(Projections.property("userName")); criteria.setProjection(p2); List listusername = criteria.list(); Iterator iter1 = listusername.iterator(); while (iter1.hasNext()) { Object[] obj1 = (Object[]) iter.next(); for (int j = 0; j < obj1.length; j++) { System.out.println("obj{j] value ---> " + obj1[j]); comment.setUser((String) obj1[j]); } } } } int averateRating = ServiceUtil.getRating(total); review.setAverage(averateRating); review.setRatings(rating); review.setComments(comments); return review; } }); return review; }
From source file:com.smartitengineering.dao.impl.hibernate.AbstractDAO.java
License:Open Source License
private void setProjection(Criteria criteria, final Projection projection) { ProjectionList currentProjections = projections.get(criteria); if (currentProjections == null) { currentProjections = Projections.projectionList(); projections.put(criteria, currentProjections); criteria.setProjection(currentProjections); }/*from w w w . ja v a2 s . co m*/ currentProjections.add(projection); }
From source file:com.square.adherent.noyau.dao.implementations.contrat.ContratDaoImpl.java
License:Open Source License
@Override public List<RatioPrestationCotisationDto> getRatioPrestationCotisationPersonne(Long uidPersonne) { final Criteria crit = createCriteria(Ratio.class); final ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.property("ratioPrestaSurCotis")); projectionList.add(Projections.property("annee")); crit.setProjection(projectionList);/*from www. j a v a2 s. c o m*/ crit.add(Restrictions.eq("uidPersonne", uidPersonne)); final List result = crit.list(); final Iterator iterator = result.iterator(); if (result == null) { return null; } else { double ratio = -1; int annee = -1; final List<RatioPrestationCotisationDto> listRatioDto = new ArrayList<RatioPrestationCotisationDto>(); while (iterator.hasNext()) { final Object[] objects = (Object[]) iterator.next(); ratio = ((Double) objects[0]).doubleValue(); annee = ((Integer) objects[1]).intValue(); final RatioPrestationCotisationDto ratioDto = new RatioPrestationCotisationDto(); ratioDto.setAnnee(annee); ratioDto.setRatioPrestationCotisation(ratio); final IdentifiantLibelleDto personneDto = new IdentifiantLibelleDto(uidPersonne); ratioDto.setPersonne(personneDto); listRatioDto.add(ratioDto); } return listRatioDto; } }
From source file:com.thesett.catalogue.impl.standalone.CatalogueManagerServiceImpl.java
License:Apache License
/** {@inheritDoc} */ public PagingResult executePagedQuery(int from, int number, String databaseEntityName, String entityTypeName, String viewTypeName, Criterion criterion, Map<String, Criterion> joins) { log.debug("public PagingResult executePagedQuery(int from = " + from + ", int number = " + number + ", String databaseEntityName = " + databaseEntityName + ", String entityTypeName = " + entityTypeName + ", String viewTypeName = " + viewTypeName + ", Criterion criterion, " + "Map<String, Criterion> joins): called"); Session session = HibernateUtil.getCurrentSession(); HibernateUtil.beginTransaction();/*from w w w.j a v a2s. co m*/ // Project the id and external id properties and just the remaining properties that are required to project // the results onto the specified view type. ProjectionList properties = Projections.projectionList().add(Projections.id()) .add(Property.forName("externalId")); ViewType viewType = getCatalogue().getViewType(viewTypeName); for (String fieldName : viewType.getAllPropertyTypes().keySet()) { properties.add(Property.forName(fieldName)); } // Create the selection criteria for the block. Criteria selectCriteria = session.createCriteria(databaseEntityName); if (criterion != null) { selectCriteria.add(criterion); } if (joins != null) { for (Map.Entry<String, Criterion> entry : joins.entrySet()) { String joinEntity = entry.getKey(); Criterion joinCriterion = entry.getValue(); selectCriteria.createCriteria(joinEntity).add(joinCriterion); } } selectCriteria.setProjection(properties).setFirstResult(from).setMaxResults(number) .setResultTransformer(new ViewInstanceTransformer(viewType, entityTypeName)); // Create the count criteria. Criteria countCriteria = session.createCriteria(databaseEntityName); if (criterion != null) { countCriteria.add(criterion); } if (joins != null) { for (Map.Entry<String, Criterion> entry : joins.entrySet()) { String joinEntity = entry.getKey(); Criterion joinCriterion = entry.getValue(); countCriteria.createCriteria(joinEntity).add(joinCriterion); } } countCriteria.setProjection(Projections.rowCount()); // Run a query to find out how many results there will be and update the list size. int count = (Integer) countCriteria.uniqueResult(); // Execute the query to get the block. List<ViewInstance> results = selectCriteria.list(); return new PagingResult(count, results); }
From source file:com.ut.tekir.invoice.yeni.LimitationChecker.java
License:LGPL
public DetachedCriteria buildCriteriaForWarehouse() { DetachedCriteria crit = DetachedCriteria.forClass(ProductTxn.class); crit.createAlias("product", "product"); crit.createAlias("warehouse", "warehouse"); ProjectionList pl = Projections.projectionList(); pl.add(Projections.groupProperty("product.code"), "prodcode") .add(Projections.groupProperty("product.name"), "prodname") .add(Projections.groupProperty("product.group"), "group") .add(Projections.groupProperty("product.barcode1"), "barcode") .add(Projections.groupProperty("warehouse.code"), "warecode") .add(Projections.groupProperty("warehouse.name"), "warename") .add(Projections.sum("quantity.value"), "quantity") .add(Projections.avg("unitPrice.value"), "unitPrice") .add(Projections.sqlGroupProjection("{alias}.UNIT as unit, " + "sum( case {alias}.trade_action when 0 then {alias}.QUANTITY else 0 end ) as INQTY, " + "sum( case {alias}.trade_action when 1 then {alias}.QUANTITY else 0 end ) as OUTQTY , " + "sum( case {alias}.trade_action when 2 then {alias}.QUANTITY else 0 end ) as BUYRETQTY, " + "sum( case {alias}.trade_action when 3 then {alias}.QUANTITY else 0 end ) as SELLRETQTY, " + "sum( case {alias}.trade_action when 6 then {alias}.QUANTITY else 0 end ) as RESQTY , " + "sum( case {alias}.trade_action when 7 then {alias}.QUANTITY else 0 end ) as DELQTY ", "UNIT", new String[] { "unit", "inqty", "outqty", "buyretqty", "sellretqty", "resqty", "delqty" }, new Type[] { Hibernate.STRING, Hibernate.DOUBLE, Hibernate.DOUBLE, Hibernate.DOUBLE, Hibernate.DOUBLE, Hibernate.DOUBLE, Hibernate.DOUBLE })); crit.setProjection(pl);//from www . j a v a 2 s. c o m crit.add(Restrictions.eq("active", true)); //Evran kendisini toplam deerlere eklemiyoruz. if (filterModel.getDocId() != null) { crit.add(Restrictions.ne("documentId", filterModel.getDocId())); } if (filterModel.getBarcode() != null && filterModel.getBarcode().length() > 0) { Criterion criteria1 = Restrictions.eq("product.barcode1", filterModel.getBarcode()); Criterion criteria2 = Restrictions.eq("product.barcode2", filterModel.getBarcode()); Criterion criteria3 = Restrictions.eq("product.barcode3", filterModel.getBarcode()); crit.add(Restrictions.or(criteria1, Restrictions.or(criteria2, criteria3))); } if (filterModel.getProduct() != null) { crit.add(Restrictions.eq("product", filterModel.getProduct())); } crit.addOrder(Order.asc("product.name")); return crit; }
From source file:com.ut.tekir.report.ProductStatusReportBean.java
License:LGPL
public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(ProductTxn.class); crit.createAlias("product", "product"); crit.createAlias("warehouse", "warehouse"); //TODO: Unit Price'n farkl dvizlerde olma sorunu zle... ProjectionList pl = Projections.projectionList(); pl.add(Projections.groupProperty("product.code"), "prodcode") .add(Projections.groupProperty("product.name"), "prodname") //.add( Projections.groupProperty("action"), "action" ) //.add( Projections.groupProperty("amount.currency"), "currency" ) .add(Projections.groupProperty("product.group"), "group") .add(Projections.groupProperty("product.barcode1"), "barcode") .add(Projections.sum("quantity.value"), "quantity") .add(Projections.avg("unitPrice.value"), "unitPrice") .add(Projections.sqlGroupProjection("{alias}.UNIT as unit, " + //"sum( case {alias}.finance_action when 0 then {alias}.QUANTITY else 0 end ) as INQTY, " + //"sum( case {alias}.finance_action when 0 then 0 else {alias}.QUANTITY end ) as OUTQTY", "sum( case {alias}.trade_action when 0 then {alias}.QUANTITY else 0 end ) as INQTY, " + "sum( case {alias}.trade_action when 1 then {alias}.QUANTITY else 0 end ) as OUTQTY , " + "sum( case {alias}.trade_action when 2 then {alias}.QUANTITY else 0 end ) as BUYRETQTY, " + "sum( case {alias}.trade_action when 3 then {alias}.QUANTITY else 0 end ) as SELLRETQTY, " + "sum( case {alias}.trade_action when 6 then {alias}.QUANTITY else 0 end ) as RESQTY , " + "sum( case {alias}.trade_action when 7 then {alias}.QUANTITY else 0 end ) as DELQTY ", "UNIT", new String[] { "unit", "inqty", "outqty", "buyretqty", "sellretqty", "resqty", "delqty" }, new Type[] { Hibernate.STRING, Hibernate.DOUBLE, Hibernate.DOUBLE, Hibernate.DOUBLE, Hibernate.DOUBLE, Hibernate.DOUBLE, Hibernate.DOUBLE })); if (warehouseBase) { //Depo krlml pl.add(Projections.groupProperty("warehouse.code"), "warecode") .add(Projections.groupProperty("warehouse.name"), "warename"); crit.addOrder(Order.asc("warehouse.code")); }/*w w w. j av a 2s .c om*/ crit.setProjection(pl); crit.add(Restrictions.eq("active", true)); if (code != null && code.length() > 0) { crit.add(Restrictions.ilike("product.code", code, MatchMode.START)); } if (name != null && name.length() > 0) { crit.add(Restrictions.ilike("product.name", name, MatchMode.START)); } if (productType != null) { if (getProductType() == 1) { crit.add(Restrictions.like("this.productType", ProductType.Product)); } else if (getProductType() == 2) { crit.add(Restrictions.like("this.productType", ProductType.Service)); } } if (barcode != null && barcode.length() > 0) { Criterion criteria1 = Restrictions.like("product.barcode1", barcode, MatchMode.START); Criterion criteria2 = Restrictions.like("product.barcode2", barcode, MatchMode.START); Criterion criteria3 = Restrictions.like("product.barcode3", barcode, MatchMode.START); crit.add(Restrictions.or(criteria1, Restrictions.or(criteria2, criteria3))); } if (group != null) { crit.add(Restrictions.eq("product.group", group)); } if (warehouse != null) { crit.add(Restrictions.eq("warehouse", warehouse)); } if (beginDate != null) { crit.add(Restrictions.ge("date", beginDate)); } if (endDate != null) { crit.add(Restrictions.le("date", endDate)); } if (category != null) { crit.add(Restrictions.eq("product.category", category)); } if (docCode != null && docCode.length() > 0) { crit.add(Restrictions.ilike("code", docCode, MatchMode.START)); } if (getDocumentType() != null && getDocumentType() != DocumentType.Unknown) { crit.add(Restrictions.eq("this.documentType", getDocumentType())); } if (getWorkBunch() != null) { crit.add(Restrictions.eq("this.workBunch", getWorkBunch())); } /* crit.addOrder( Order.asc("date")); crit.addOrder( Order.asc("serial")); * */ crit.addOrder(Order.asc("product.name")); log.debug("Sonu : #0", crit); return crit; }
From source file:com.ut.tekir.stock.ProductTxnReportBean.java
License:LGPL
public DetachedCriteria buildCriteriaForWarehouse() { DetachedCriteria crit = DetachedCriteria.forClass(ProductTxn.class); crit.createAlias("product", "product"); crit.createAlias("warehouse", "warehouse"); ProjectionList pl = Projections.projectionList(); pl.add(Projections.groupProperty("product.code"), "prodcode") .add(Projections.groupProperty("product.name"), "prodname") .add(Projections.groupProperty("product.group"), "group") .add(Projections.groupProperty("product.barcode1"), "barcode") .add(Projections.groupProperty("warehouse.code"), "warecode") .add(Projections.groupProperty("warehouse.name"), "warename") .add(Projections.sum("quantity.value"), "quantity") .add(Projections.avg("unitPrice.value"), "unitPrice") .add(Projections.sqlGroupProjection("{alias}.UNIT as unit, " + "sum( case {alias}.trade_action when 0 then {alias}.QUANTITY else 0 end ) as INQTY, " + "sum( case {alias}.trade_action when 1 then {alias}.QUANTITY else 0 end ) as OUTQTY , " + "sum( case {alias}.trade_action when 2 then {alias}.QUANTITY else 0 end ) as BUYRETQTY, " + "sum( case {alias}.trade_action when 3 then {alias}.QUANTITY else 0 end ) as SELLRETQTY, " + "sum( case {alias}.trade_action when 6 then {alias}.QUANTITY else 0 end ) as RESQTY , " + "sum( case {alias}.trade_action when 7 then {alias}.QUANTITY else 0 end ) as DELQTY ", "UNIT", new String[] { "unit", "inqty", "outqty", "buyretqty", "sellretqty", "resqty", "delqty" }, new Type[] { Hibernate.STRING, Hibernate.DOUBLE, Hibernate.DOUBLE, Hibernate.DOUBLE, Hibernate.DOUBLE, Hibernate.DOUBLE, Hibernate.DOUBLE })); crit.setProjection(pl);// ww w.j ava 2 s .c o m crit.add(Restrictions.eq("active", true)); if (filterModel.getBarcode() != null && filterModel.getBarcode().length() > 0) { Criterion criteria1 = Restrictions.eq("product.barcode1", filterModel.getBarcode()); Criterion criteria2 = Restrictions.eq("product.barcode2", filterModel.getBarcode()); Criterion criteria3 = Restrictions.eq("product.barcode3", filterModel.getBarcode()); crit.add(Restrictions.or(criteria1, Restrictions.or(criteria2, criteria3))); } if (filterModel.getProduct() != null) { crit.add(Restrictions.eq("product", filterModel.getProduct())); } crit.addOrder(Order.asc("product.name")); return crit; }
From source file:dao.DaoImplementProductos.java
public int getUltimoProducto() { Session session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction();//w ww .ja v a 2s . co m Criteria criteria = session.createCriteria(Productos.class); ProjectionList projList = Projections.projectionList(); projList.add(Projections.max("idproducto")); criteria.setProjection(projList); List results = criteria.list(); Iterator iterator = results.iterator(); int ultReg = 0; while (iterator.hasNext()) { ultReg = Integer.parseInt(iterator.next().toString()); } session.close(); return ultReg; }
From source file:de.lemo.dms.connectors.lemo_0_8.ExtractAndMap.java
License:Open Source License
/** * Reads the Mining Database.//w w w .ja va 2s . c om * 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; } Criteria criteria = session.createCriteria(PlatformLMS.class, "obj"); // load objects which are already in Mining DB for associations 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; }