List of usage examples for org.hibernate Criteria createAlias
public Criteria createAlias(String associationPath, String alias) throws HibernateException;
From source file:br.com.muranodesign.dao.impl.TutoriaDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<Tutoria> listarPeriodo(int id) { Criteria criteria = getSession().createCriteria(Tutoria.class); criteria.createAlias("periodo", "periodo"); criteria.add(Restrictions.eq("periodo.idperiodo", id)); criteria.addOrder(Order.asc("tutoria")); List<Tutoria> result = criteria.list(); return result; }
From source file:br.com.muranodesign.dao.impl.UsuarioDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<Usuario> listaAluno(int idAluno) { Criteria criteria = getSession().createCriteria(Usuario.class); criteria.createAlias("aluno", "aluno"); criteria.add(Restrictions.eq("aluno.idAluno", idAluno)); List<Usuario> result = criteria.list(); return result; }
From source file:br.com.muranodesign.dao.impl.UsuarioDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<Usuario> listarProfessor(int idProfessor) { Criteria criteria = getSession().createCriteria(Usuario.class); criteria.createAlias("professor", "professor"); criteria.add(Restrictions.eq("professor.idprofessorFuncionario", idProfessor)); List<Usuario> result = criteria.list(); return result; }
From source file:br.com.muranodesign.dao.impl.UsuarioDAOImpl.java
License:Creative Commons License
@Override public List<Usuario> listarPerfil(int idPerfil) { Criteria criteria = getSession().createCriteria(Usuario.class); criteria.createAlias("perfil", "perfil"); criteria.add(Restrictions.eq("perfil.idperfil", idPerfil)); List<Usuario> result = criteria.list(); return result; }
From source file:br.com.webbudget.domain.model.repository.entries.CardInvoiceRepository.java
License:Open Source License
/** * * @param card// ww w . j av a2 s. com * @return */ @Override public List<CardInvoice> listByCard(Card card) { final Criteria criteria = this.createCriteria(); criteria.createAlias("card", "ca"); criteria.add(Restrictions.eq("ca.id", card.getId())); return criteria.list(); }
From source file:br.com.webbudget.domain.model.repository.entries.CardInvoiceRepository.java
License:Open Source License
/** * * @param movement/*from ww w . ja va2 s .c om*/ * @return */ @Override public CardInvoice findByMovement(Movement movement) { final Criteria criteria = this.getSession().createCriteria(this.getPersistentClass()); criteria.createAlias("movement", "mv"); criteria.add(Restrictions.eq("mv.id", movement.getId())); return (CardInvoice) criteria.uniqueResult(); }
From source file:br.com.webbudget.domain.model.repository.entries.CardInvoiceRepository.java
License:Open Source License
/** * * @param card//w w w . jav a 2 s . c o m * @param pageRequest * @return */ @Override public Page<CardInvoice> listByCard(Card card, PageRequest pageRequest) { final Criteria criteria = this.createCriteria(); // filtra if (card != null) { criteria.createAlias("card", "ca"); criteria.add(Restrictions.eq("ca.id", card.getId())); } // projetamos para pegar o total de paginas possiveis criteria.setProjection(Projections.count("id")); final Long totalRows = (Long) criteria.uniqueResult(); // limpamos a projection para que a criteria seja reusada criteria.setProjection(null); criteria.setResultTransformer(Criteria.ROOT_ENTITY); // paginamos criteria.setFirstResult(pageRequest.getFirstResult()); criteria.setMaxResults(pageRequest.getPageSize()); if (pageRequest.getSortDirection() == PageRequest.SortDirection.ASC) { criteria.addOrder(Order.asc(pageRequest.getSortField())); } else if (pageRequest.getSortDirection() == PageRequest.SortDirection.DESC) { criteria.addOrder(Order.desc(pageRequest.getSortField())); } // montamos o resultado paginado return new Page<>(criteria.list(), totalRows); }
From source file:br.com.webbudget.domain.model.repository.entries.CostCenterRepository.java
License:Open Source License
/** * * @param name/* w ww . j av a 2s.com*/ * @param parent * @return */ @Override public CostCenter findByNameAndParent(String name, CostCenter parent) { final Criteria criteria = this.getSession().createCriteria(this.getPersistentClass()); if (parent != null) { criteria.createAlias("parentCostCenter", "pcc"); criteria.add(Restrictions.eq("pcc.name", parent.getName())); } else { criteria.add(Restrictions.isNull("parentCostCenter")); } criteria.add(Restrictions.eq("name", name)); return (CostCenter) criteria.uniqueResult(); }
From source file:br.com.webbudget.domain.model.repository.entries.MovementClassRepository.java
License:Open Source License
/** * * @param costCenter/*w ww .j a v a2 s .c om*/ * @return */ @Override public List<MovementClass> listByCostCenterAndType(CostCenter costCenter, MovementClassType type) { final Criteria criteria = this.getSession().createCriteria(this.getPersistentClass()); criteria.createAlias("costCenter", "cc"); criteria.add(Restrictions.eq("cc.id", costCenter.getId())); if (type != null) { criteria.add(Restrictions.eq("movementClassType", type)); } criteria.add(Restrictions.eq("blocked", false)); criteria.addOrder(Order.asc("name")); return criteria.list(); }
From source file:br.com.webbudget.domain.model.repository.entries.MovementClassRepository.java
License:Open Source License
/** * * @param name/*from w ww. j a v a2 s. c o m*/ * @param type * @param costCenter * @return */ @Override public MovementClass findByNameAndTypeAndCostCenter(String name, MovementClassType type, CostCenter costCenter) { final Criteria criteria = this.getSession().createCriteria(this.getPersistentClass()); criteria.createAlias("costCenter", "cc"); criteria.add(Restrictions.eq("cc.id", costCenter.getId())); criteria.add(Restrictions.eq("name", name)); criteria.add(Restrictions.eq("movementClassType", type)); return (MovementClass) criteria.uniqueResult(); }