List of usage examples for org.hibernate Criteria addOrder
public Criteria addOrder(Order order);
From source file:br.com.hslife.orcamento.repository.LogRepository.java
License:Open Source License
@SuppressWarnings("unchecked") public List<Logs> findByCriteriosLog(CriterioLog criterioBusca) { Criteria criteria = getSession().createCriteria(Logs.class); for (Criterion criterion : criterioBusca.buildCriteria()) { criteria.add(criterion);//from w ww . j a v a 2 s . c o m } return criteria.addOrder(Order.desc("logDate")).list(); }
From source file:br.com.hslife.orcamento.repository.MeioPagamentoRepository.java
License:Open Source License
@SuppressWarnings("unchecked") public List<MeioPagamento> findByDescricaoAndUsuario(String descricao, Usuario usuario) { Criteria criteria = getSession().createCriteria(MeioPagamento.class); criteria.add(Restrictions.ilike("descricao", descricao, MatchMode.ANYWHERE)); criteria.add(Restrictions.eq("usuario.id", usuario.getId())); return criteria.addOrder(Order.asc("descricao")).list(); }
From source file:br.com.hslife.orcamento.repository.MeioPagamentoRepository.java
License:Open Source License
@SuppressWarnings("unchecked") public List<MeioPagamento> findByUsuario(Usuario usuario) { Criteria criteria = getSession().createCriteria(MeioPagamento.class); criteria.add(Restrictions.eq("usuario.id", usuario.getId())); return criteria.addOrder(Order.asc("descricao")).list(); }
From source file:br.com.hslife.orcamento.repository.MeioPagamentoRepository.java
License:Open Source License
@SuppressWarnings("unchecked") public List<MeioPagamento> findEnabledByUsuario(Usuario usuario) { Criteria criteria = getSession().createCriteria(MeioPagamento.class); criteria.add(Restrictions.eq("ativo", true)); criteria.add(Restrictions.eq("usuario.id", usuario.getId())); return criteria.addOrder(Order.asc("descricao")).list(); }
From source file:br.com.hslife.orcamento.repository.UnidadeMedidaRepository.java
License:Open Source License
@SuppressWarnings("unchecked") public List<UnidadeMedida> findByDescricaoAndUsuario(String descricao, Usuario usuario) { Criteria criteria = getSession().createCriteria(UnidadeMedida.class); criteria.add(Restrictions.ilike("descricao", descricao, MatchMode.ANYWHERE)); criteria.add(Restrictions.eq("usuario.id", usuario.getId())); return criteria.addOrder(Order.asc("descricao")).list(); }
From source file:br.com.hslife.orcamento.repository.UnidadeMedidaRepository.java
License:Open Source License
@SuppressWarnings("unchecked") public List<UnidadeMedida> findByUsuario(Usuario usuario) { Criteria criteria = getSession().createCriteria(UnidadeMedida.class); criteria.add(Restrictions.eq("usuario.id", usuario.getId())); return criteria.addOrder(Order.asc("descricao")).list(); }
From source file:br.com.hslife.orcamento.repository.UsuarioRepository.java
License:Open Source License
@SuppressWarnings("unchecked") public List<Usuario> findAllByLogin(String login) { Criteria criteria = getSession().createCriteria(Usuario.class); criteria.add(Restrictions.ilike("login", login, MatchMode.ANYWHERE)); return criteria.addOrder(Order.asc("nome")).list(); }
From source file:br.com.itw.commons.persistence.PageableHelper.java
License:Apache License
public static Page<?> getPage(Criteria criteria, Pageable pageable) { // Count// w w w .ja v a2 s . c om Long totalItems = (Long) criteria.setProjection(Projections.rowCount()).uniqueResult(); // Pageable result Result criteria.setProjection(null).setResultTransformer(CriteriaSpecification.ROOT_ENTITY); if (pageable.getSort() != null) { Iterator<Sort.Order> orders = pageable.getSort().iterator(); while (orders.hasNext()) { Sort.Order order = orders.next(); if (order.getDirection() == null || Sort.Direction.ASC.equals(order.getDirection())) { criteria.addOrder(Order.asc(order.getProperty())); } else { criteria.addOrder(Order.desc(order.getProperty())); } } } List<?> result = criteria.setFirstResult(pageable.getPageNumber() * pageable.getPageSize()) .setMaxResults(pageable.getPageSize()).list(); return (Page<?>) new PageImpl<>(result, pageable, totalItems); }
From source file:br.com.jn.dao.CandidatoDAO.java
public List<Candidato> listar() { Authentication a = SecurityContextHolder.getContext().getAuthentication(); //Authentication authentication = context.getAuthentication(); Object principal = a.getPrincipal(); String username = ""; username = (((User) a.getPrincipal()).getUsername()); //username = ((UserDetails) principal).getUsername(); System.out.println("login selecionado:" + username); Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();//from w ww .j ava 2 s. com String sql = "select * from users where username = :username"; SQLQuery query = session.createSQLQuery(sql); query.addEntity(Users.class); query.setParameter("username", username); //Users usuario = (Users) query.uniqueResult(); List logado = query.list(); //List<Users> results = query.getResultList(); String UserId = logado.get(0).toString(); String usuario = "4"; //System.out.println("Id do usuario selecionado:" + usuario.getUserId()); //System.out.println("Id do usuario selecionado:" + usuario.getNome()); //Integer UserId = usuario.getUserId(); System.out.println("Id do usuario selecionado:" + UserId); Criteria crit = session.createCriteria(Candidato.class); crit.add(Restrictions.ge("notaEliminatoria", (5.0))); crit.add(Restrictions.eq("orientador1", username)); crit.addOrder(Order.asc("nome")); List<Candidato> lista = crit.list(); session.close(); return lista; }
From source file:br.com.machina.verbum.dao.hibernate.PostDAOImpl.java
License:Apache License
@SuppressWarnings("unchecked") public List<Post> findAll() { final Criteria criteria = session.createCriteria(Post.class); criteria.add(Restrictions.eq("draft", false)); criteria.addOrder(Order.desc("date")); return criteria.list(); }