Java Code Examples for org.springframework.expression.spel.ast.Projection

Following code examples demonstrate how to use org.springframework.expression.spel.ast.Projection from spring-framework. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.springframework.expression.spel.ast.Projection and various code implementation of this class.
Example 1
Project : spring-framework Source File : BookDAOImpl.java View Source Code on GitHub

    public BookDAOImpl(){
        bookProjection = Projections.projectionList();
        bookProjection.add(Projections.property("id"), "id");
        bookProjection.add(Projections.property("name"), "name");
        bookProjection.add(Projections.property("image"), "image");
        bookProjection.add(Projections.property("genre"), "genre");
        bookProjection.add(Projections.property("pageCount"), "pageCount");
        bookProjection.add(Projections.property("isbn"), "isbn");
        bookProjection.add(Projections.property("publisher"), "publisher");
        bookProjection.add(Projections.property("author"), "author");
        bookProjection.add(Projections.property("publishYear"), "publishYear");
        bookProjection.add(Projections.property("descr"), "descr");
        bookProjection.add(Projections.property("rating"), "rating");
        bookProjection.add(Projections.property("voteCount"), "voteCount");
    }
			
Example 2
Project : spring-framework Source File : CriteriaUtil.java View Source Code on GitHub

	public static void main(String args[]){
        ApplicationContext context = new ClassPathXmlApplicationContext("mvc-dispatcher-servlet.xml");
        SessionFactory sessionFactory = (SessionFactory)context.getBean("mySessionFactory");
        Session openSession = sessionFactory.openSession();
	
        Criteria createCriteria = openSession.createCriteria(Employee.class);
        Criteria add = createCriteria.add(Restrictions.like("ADDRESS","test"));
        ProjectionList projectionList = Projections.projectionList();
        projectionList.add(Projections.property("ADDRESS"));
        projectionList.add(Projections.property("department.DEPTID"));
		Criteria setProjection = add.setProjection(projectionList);
        List list = setProjection.list();
        for (Object employee : list) {
        	Object[] arrray = (Object[])employee;
			System.out.println(arrray[0]+":"+arrray[1]);
		}
	}
			
Example 3
Project : spring-framework Source File : EmployeeSkillDAOImpl.java View Source Code on GitHub

	public List<Integer> getAllEmployeeCode(int skillCode) {
		Criteria criteria=sessionFactory.getCurrentSession().createCriteria(EmployeeSkill.class);
		criteria.add(Restrictions.eq("skillCode",skillCode));
		PropertyProjection p=Projections.property("empCode");
		List<Integer> codeList=criteria.setProjection(p).list();
		return codeList;
	}
			
Example 4
Project : spring-framework Source File : ApplicationDao.java View Source Code on GitHub

	public void getRowCount() {
		DetachedCriteria criteria = getCriteria(Department.class);
		criteria.setProjection(Projections.projectionList()				
				.add(Projections.groupProperty("name"),"name")
				.add(Projections.rowCount(),"count"));
		criteria.setResultTransformer(Transformers.aliasToBean(GroupCount.class));
		List<GroupCount> result = (List<GroupCount>) getHibernateTemplate().findByCriteria(criteria);
		result.forEach(item -> {
			System.out.println(item.getName() + " " + item.getCount());
		});

	}
			
Example 5
Project : spring-framework Source File : StorageDAOImpl.java View Source Code on GitHub

	public Collection<Product> getAllProductInStorage(int id) {

		Criteria criteria = HibernateUtils.getCurrentSession()
				.createCriteria(Storage.class)
				.setProjection(Projections.projectionList()
					      .add(Projections.property("products"), "products"))
				.add(Restrictions.like("id", id))
				.setResultTransformer(Transformers.aliasToBean(Product.class));
		return (Collection<Product>) criteria.list().get(0);
	}
			
Example 6
Project : spring-framework Source File : BaseDaoImpl.java View Source Code on GitHub

	public void pageQuery(PageBean pageBean) {
		Integer currentPage = pageBean.getCurrentPage();
		Integer pageSize = pageBean.getPageSize();
		DetachedCriteria detachedCriteria = pageBean.getDetachedCriteria();
		
		detachedCriteria.setProjection(Projections.rowCount());
		List<?> countList = getHibernateTemplate().findByCriteria(detachedCriteria);
		long total = (long) countList.get(0);
		pageBean.setTotal((int)total);
		
		detachedCriteria.setProjection(null);
		int firstResult = (currentPage - 1) * pageSize;
		List<?> rows = getHibernateTemplate().findByCriteria(detachedCriteria, firstResult, pageSize);
		pageBean.setRows(rows);
	}
			
Example 7
Project : spring-framework Source File : CustomerDaoImpl.java View Source Code on GitHub

	public PageBean<Customer> findByPage(Integer currentPage, Integer pageSize, DetachedCriteria criteria) {
		PageBean<Customer> page = new PageBean<Customer>();
		page.setCurrentPage(currentPage);
		page.setPageSize(pageSize);
		
		criteria.setProjection(Projections.rowCount());
		List<Number> list = (List<Number>) this.getHibernateTemplate().findByCriteria(criteria);
		if(list != null && list.size() > 0){
			int totalCount = list.get(0).intValue();
			page.setTotalCount(totalCount);
		}
		
		criteria.setProjection(null);
		List<Customer> beanList = (List<Customer>) this.getHibernateTemplate().findByCriteria(criteria, (currentPage-1)*pageSize, pageSize);
		page.setBeanList(beanList);
		return page;
	}
			
Example 8
Project : spring-framework Source File : ServiceCheckDaoImpl.java View Source Code on GitHub

	public ServiceCheck findLastByIdService(int serviceId) {
		Criteria crit = createEntityCriteria();
		crit.add(Restrictions.eq("service_id", serviceId));
		ProjectionList projectionList = Projections.projectionList();
		projectionList.add(Projections.max("CHECK_TIME"));
		crit.setProjection(projectionList);
		crit.setMaxResults(1);
		ServiceCheck serviceCheck = (ServiceCheck)crit.list();
		return serviceCheck;
	}
			
Example 9
Project : spring-framework Source File : CustomerDaoImp.java View Source Code on GitHub

	public Integer findCount(DetachedCriteria detachedCriteria) {
		detachedCriteria.setProjection(Projections.rowCount());
		List<Long> list  = (List<Long>) this.getHibernateTemplate().findByCriteria(detachedCriteria);
		if(list.size()>0){
			return list.get(0).intValue();
		}
		return null;
	}