List of usage examples for org.hibernate Criteria createAlias
public Criteria createAlias(String associationPath, String alias) throws HibernateException;
From source file:au.org.theark.report.model.dao.ReportDao.java
License:Open Source License
public Phone getHomePhone(LinkSubjectStudy subject) { Phone result = null;/*from w w w . j av a 2s. c o m*/ Criteria criteria = getSession().createCriteria(Phone.class); criteria.add(Restrictions.eq("person", subject.getPerson())); criteria.createAlias("phoneType", "pt"); criteria.add(Restrictions.eq("pt.name", "Home")); criteria.setMaxResults(1); ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.property("areaCode"), "areaCode"); projectionList.add(Projections.property("phoneNumber"), "phoneNumber"); criteria.setProjection(projectionList); // only return fields required for report criteria.setResultTransformer(Transformers.aliasToBean(Phone.class)); if (criteria.uniqueResult() != null) { result = (Phone) criteria.uniqueResult(); } return result; }
From source file:au.org.theark.report.model.dao.ReportDao.java
License:Open Source License
public List<FieldDetailsDataRow> getPhenoFieldDetailsList(FieldDetailsReportVO fdrVO) { List<FieldDetailsDataRow> results = new ArrayList<FieldDetailsDataRow>(); Criteria criteria = getSession().createCriteria(PhenoDataSetCollection.class, "fpc"); criteria.createAlias("phenoCollection", "pc"); // Inner join to Field criteria.createAlias("field", "f"); // Inner join to Field criteria.createAlias("f.fieldType", "ft"); // Inner join to FieldType criteria.add(Restrictions.eq("study", fdrVO.getStudy())); if (fdrVO.getPhenoCollection() != null) { criteria.add(Restrictions.eq("phenoCollection", fdrVO.getPhenoCollection())); }// ww w .ja v a 2s. c o m if (fdrVO.getFieldDataAvailable()) { DetachedCriteria fieldDataCriteria = DetachedCriteria.forClass(PhenoDataSetData.class, "fd"); // Join FieldPhenoCollection and FieldData on ID FK fieldDataCriteria.add(Property.forName("f.id").eqProperty("fd." + "field.id")); fieldDataCriteria.add(Property.forName("pc.id").eqProperty("fd." + "collection.id")); criteria.add(Subqueries.exists(fieldDataCriteria.setProjection(Projections.property("fd.id")))); } ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.property("pc.name"), "collection"); projectionList.add(Projections.property("f.name"), "fieldName"); projectionList.add(Projections.property("f.description"), "description"); projectionList.add(Projections.property("f.minValue"), "minValue"); projectionList.add(Projections.property("f.maxValue"), "maxValue"); projectionList.add(Projections.property("f.encodedValues"), "encodedValues"); projectionList.add(Projections.property("f.missingValue"), "missingValue"); projectionList.add(Projections.property("f.units"), "units"); projectionList.add(Projections.property("ft.name"), "type"); criteria.setProjection(projectionList); // only return fields required for report criteria.setResultTransformer(Transformers.aliasToBean(FieldDetailsDataRow.class)); criteria.addOrder(Order.asc("pc.id")); criteria.addOrder(Order.asc("f.name")); results = criteria.list(); return results; }
From source file:br.com.bb.intranet.supermt.governo.repository.Interacoes.java
public List<Interacao> porMci(String mci) { Criteria criteria = criarCriteria(); criteria.createAlias("interacao.empresa", "cliente"); criteria.add(Restrictions.eq("cliente.mci", mci)); return criteria.list(); }
From source file:br.com.muranodesign.dao.impl.AlunoVariavelDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<AlunoVariavel> listaAluno(int idAluno) { Criteria criteria = getSession().createCriteria(AlunoVariavel.class); criteria.add(Restrictions.eq("ativo", 1)); String ano = Integer.toString(Calendar.getInstance().get(Calendar.YEAR)); AnoLetivo anoLetivo = new AnoLetivoService().listarAnoLetivo(ano).get(0); criteria.add(Restrictions.eq("anoLetivo", anoLetivo)); criteria.createAlias("aluno", "aluno"); criteria.add(Restrictions.eq("aluno.idAluno", idAluno)); List<AlunoVariavel> result = criteria.list(); return result; }
From source file:br.com.muranodesign.dao.impl.AlunoVariavelDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<AlunoVariavel> listaAlunoInativo(int idAluno) { Criteria criteria = getSession().createCriteria(AlunoVariavel.class); String ano = Integer.toString(Calendar.getInstance().get(Calendar.YEAR)); AnoLetivo anoLetivo = new AnoLetivoService().listarAnoLetivo(ano).get(0); criteria.add(Restrictions.eq("anoLetivo", anoLetivo)); criteria.createAlias("aluno", "aluno"); criteria.add(Restrictions.eq("aluno.idAluno", idAluno)); List<AlunoVariavel> result = criteria.list(); return result; }
From source file:br.com.muranodesign.dao.impl.AlunoVariavelDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<AlunoVariavel> listaGrupo(int idGrupo) { Criteria criteria = getSession().createCriteria(AlunoVariavel.class); criteria.createAlias("grupo", "grupo"); criteria.add(Restrictions.eq("grupo.idgrupo", idGrupo)); String ano = Integer.toString(Calendar.getInstance().get(Calendar.YEAR)); AnoLetivo anoLetivo = new AnoLetivoService().listarAnoLetivo(ano).get(0); criteria.add(Restrictions.eq("anoLetivo", anoLetivo)); criteria.add(Restrictions.eq("ativo", 1)); criteria.addOrder(Order.asc("aluno")); List<AlunoVariavel> result = criteria.list(); return result; }
From source file:br.com.muranodesign.dao.impl.AlunoVariavelDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<AlunoVariavel> listaAnoEstudoPeriodo(AnoEstudo ano, Periodo periodo, int anoLetivo) { Criteria criteria = getSession().createCriteria(AlunoVariavel.class); criteria.add(Restrictions.eq("anoEstudo", ano)); criteria.add(Restrictions.eq("periodo", periodo)); criteria.add(Restrictions.eq("ativo", 1)); criteria.createAlias("anoLetivo", "anoLetivo"); criteria.add(Restrictions.eq("anoLetivo.idanoLetivo", anoLetivo)); //criteria.add(Restrictions.isNull("grupo")); List<AlunoVariavel> result = criteria.list(); return result; }
From source file:br.com.muranodesign.dao.impl.AlunoVariavelDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<AlunoVariavel> ListarCicloAno(List<Integer> i, int primeiro, int ultimo) { Criteria criteria = getSession().createCriteria(AlunoVariavel.class); criteria.createAlias("anoEstudo", "anoEstudo"); criteria.add(Restrictions.in("anoEstudo.idanoEstudo", i)); String ano = Integer.toString(Calendar.getInstance().get(Calendar.YEAR)); AnoLetivo anoLetivo = new AnoLetivoService().listarAnoLetivo(ano).get(0); criteria.add(Restrictions.eq("anoLetivo", anoLetivo)); criteria.add(Restrictions.eq("ativo", 1)); criteria.addOrder(Order.asc("anoEstudo.ano")); criteria.createAlias("aluno", "aluno"); criteria.addOrder(Order.asc("aluno.nome")); criteria.setFirstResult(primeiro);//from w w w. j a v a 2 s .c om criteria.setMaxResults(ultimo); List<AlunoVariavel> result = criteria.list(); return result; }
From source file:br.com.muranodesign.dao.impl.AlunoVariavelDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<AlunoVariavel> ListarCicloAnoPeriodo(List<Integer> i, int periodo, int primeiro, int ultimo) { Criteria criteria = getSession().createCriteria(AlunoVariavel.class); criteria.createAlias("anoEstudo", "anoEstudo"); criteria.add(Restrictions.in("anoEstudo.idanoEstudo", i)); String ano = Integer.toString(Calendar.getInstance().get(Calendar.YEAR)); AnoLetivo anoLetivo = new AnoLetivoService().listarAnoLetivo(ano).get(0); criteria.add(Restrictions.eq("anoLetivo", anoLetivo)); criteria.add(Restrictions.eq("ativo", 1)); criteria.createAlias("periodo", "periodo"); criteria.add(Restrictions.eq("periodo.idperiodo", periodo)); criteria.addOrder(Order.asc("anoEstudo.ano")); criteria.createAlias("aluno", "aluno"); criteria.addOrder(Order.asc("aluno.nome")); criteria.setFirstResult(primeiro);/*from ww w .java2s . co m*/ criteria.setMaxResults(ultimo); List<AlunoVariavel> result = criteria.list(); return result; }
From source file:br.com.muranodesign.dao.impl.AlunoVariavelDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<AlunoVariavel> ListarRangePeriodo(int id, int primeiro, int ultimo) { Criteria criteria = getSession().createCriteria(AlunoVariavel.class); criteria.createAlias("periodo", "periodo"); criteria.add(Restrictions.eq("periodo.idperiodo", id)); String ano = Integer.toString(Calendar.getInstance().get(Calendar.YEAR)); AnoLetivo anoLetivo = new AnoLetivoService().listarAnoLetivo(ano).get(0); criteria.add(Restrictions.eq("anoLetivo", anoLetivo)); criteria.add(Restrictions.eq("ativo", 1)); criteria.addOrder(Order.asc("anoEstudo.ano")); criteria.createAlias("aluno", "aluno"); criteria.addOrder(Order.asc("aluno.nome")); criteria.setFirstResult(primeiro);/*from ww w .j a v a 2s .c om*/ criteria.setMaxResults(ultimo); List<AlunoVariavel> result = criteria.list(); return result; }