List of usage examples for org.hibernate.criterion Restrictions eq
public static SimpleExpression eq(String propertyName, Object value)
From source file:ar.edu.unju.fi.apu.dao.impl.TipoProductoDAOImpl.java
@Override public TipoProducto obtenerTipoProducto(String nombre) { TipoProducto tipoProducto = null;// w w w . j a v a 2 s .co m Session session = HibernateUtil.getSessionFactory().openSession(); Criteria criteria = session.createCriteria(TipoProducto.class); criteria.add(Restrictions.eq("nombre", nombre)); if (!criteria.list().isEmpty()) { tipoProducto = (TipoProducto) criteria.list().get(0); } return tipoProducto; }
From source file:ar.edu.unju.fi.apu.dao.impl.UsuarioDAOImpl.java
@Override public Usuario validarUsuario(String nombreUsuario, String password) { Usuario usuario = null;//from www . j a va2s . co m Session session = HibernateUtil.getSessionFactory().openSession(); Criteria criteria = session.createCriteria(Usuario.class); criteria.add(Restrictions.eq("nombreUsuario", nombreUsuario));//filtro por exactitud criteria.add(Restrictions.eq("password", password)); if (!criteria.list().isEmpty()) { usuario = (Usuario) criteria.list().get(0); } return usuario; }
From source file:ar.edu.unju.fi.apu.dao.impl.UsuarioDAOImpl.java
@Override public Usuario validarNombre(String nombreUsuario) { Usuario usuario = null;/*from ww w. j av a 2s .co m*/ Session session = HibernateUtil.getSessionFactory().openSession(); Criteria criteria = session.createCriteria(Usuario.class); criteria.add(Restrictions.eq("nombreUsuario", nombreUsuario));//filtro por exactitud if (!criteria.list().isEmpty()) { return usuario; } usuario = (Usuario) criteria.list().get(0); System.out.println("sss" + usuario.getNombreReal()); return usuario; }
From source file:at.ac.tuwien.ifs.tita.dao.project.TiTAProjectDao.java
License:Apache License
/** {@inheritDoc} **/ @SuppressWarnings("unchecked") @Override/*from w w w.j a v a 2 s . c o m*/ public List<TiTAProject> findProjectsOrderedByName(int maxResult, String orderBy) throws PersistenceException { Criteria crit = getSession().createCriteria(TiTAProject.class); if (maxResult > 0) { crit.setMaxResults(maxResult); } crit.add(Restrictions.eq("deleted", false)); crit.addOrder(Order.asc(orderBy)); crit.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY); return crit.list(); }
From source file:at.ac.tuwien.ifs.tita.dao.task.TiTATaskDao.java
License:Apache License
/** {@inheritDoc} */ @Override//from w w w .j a va2s .c om public List<TiTATask> findTiTATasksforUserProject(TiTAProject project, TiTAUser user) { return findByCriteria( new Criterion[] { Restrictions.eq("titaProject", project), Restrictions.eq("user", user) }); }
From source file:at.ac.tuwien.ifs.tita.dao.time.EffortDao.java
License:Apache License
/** {@inheritDoc} */ public List<Effort> getTimeEffortsMonthlyView(Integer year, Integer month, TiTAUser user) { Calendar start = Calendar.getInstance(); Calendar end = Calendar.getInstance(); start.set(year, month, 1);//w w w .j ava2 s . c o m end.set(year, month, start.getActualMaximum(Calendar.DAY_OF_MONTH)); return findByCriteriaOrdered( new Criterion[] { Restrictions.between("date", start.getTime(), end.getTime()), Restrictions.eq("deleted", false), Restrictions.eq("user", user) }, new Order[] { Property.forName("date").asc() }, new String[] {}); }
From source file:at.ac.tuwien.ifs.tita.dao.time.EffortDao.java
License:Apache License
/** {@inheritDoc} */ @Override//w ww. j a v a 2 s . c o m public List<Effort> findEffortsForTimeConsumerId(Long tcId) { Criterion criterions[] = null; Order order[] = { Order.asc("date") }; criterions = new Criterion[] { Restrictions.eq("user.id", tcId) }; return findByCriteriaOrdered(criterions, order, null); }
From source file:at.ac.tuwien.swa.swazam.server.UserRequestHistoryRepo.java
public UserRequestHistory read(long id) { Session session = factory.openSession(); try {/*from w ww. j a va 2 s . co m*/ return (UserRequestHistory) session.createCriteria(UserRequestHistory.class) .add(Restrictions.eq("userName", id)).uniqueResult(); } catch (HibernateException e) { } finally { session.close(); } return null; }
From source file:au.com.optus.mcas.sdp.bizservice.ott.ordertracking.batchjob.dao.impl.OttOmpOrderTrackScheduleDaoImpl.java
License:Open Source License
/** * This method retrieves the record using the batch name and return the * OttOmpOrderTrackSchedule object.//from w w w . ja v a2 s . c o m * @param batchName * String * @return OttOmpOrderTrackSchedule */ public OttOmpOrderTrackSchedule retrieveOrderTrackingSchdule(String batchName) { LOG.info("retrieveOrderTrackingSchdule Method ----------- STARTS"); OttOmpOrderTrackSchedule ottOmpOrderTrackSchedule = null; if (StringUtils.isNotEmpty(batchName)) { DetachedCriteria criteria = super.createDetachedCriteria(); criteria.add(Restrictions.eq("batchName", batchName)); List<OttOmpOrderTrackSchedule> ottOmpOrderTrackScheduleList = findByCriteria(criteria); if (!ottOmpOrderTrackScheduleList.isEmpty()) { LOG.debug("OttOmpOrderTrackScheduleDaoImpl : retrieveOrderTrackingSchdule : " + "Record found for batch name " + batchName + " in OTT_OMP_ORDER_TRACK_SCHEDULE table"); ottOmpOrderTrackSchedule = ottOmpOrderTrackScheduleList.get(0); return ottOmpOrderTrackSchedule; } } LOG.debug( "OttOmpOrderTrackScheduleDaoImpl : retrieveOrderTrackingSchdule : Record not found for batch name " + batchName + " in OTT_OMP_ORDER_TRACK_SCHEDULE table"); LOG.info("retrieveOrderTrackingSchdule Method ----------- ENDS"); return ottOmpOrderTrackSchedule; }
From source file:au.com.optus.mcas.sdp.bizservice.ott.ordertracking.batchjob.dao.impl.OttOrderActivityDaoImpl.java
License:Open Source License
/** * This method is used to retrieve OrderTrackingActivityDetails using the last success run * and return the list of OttOrderActivity objects. * @param lastSuccessRun//w w w .ja v a 2s.c o m * Date * @return List */ public List<OttOrderActivity> retrieveOrderTrackingActivityDetails(Date lastSuccessRun) { LOG.info("retrieveOrderTrackingActivityDetails Method ----------- STARTS"); List<OttOrderActivity> ottOrderActivityList = new ArrayList<OttOrderActivity>(); if (lastSuccessRun != null) { DetachedCriteria criteria = super.createDetachedCriteria(); Calendar c = Calendar.getInstance(); c.setTime(lastSuccessRun); Date time = c.getTime(); criteria.add(Restrictions.disjunction().add(Restrictions.eq("transitionTaskModifiedTime", time)) .add(Restrictions.gt("transitionTaskModifiedTime", time))); ottOrderActivityList = findByCriteria(criteria); if (!ottOrderActivityList.isEmpty()) { LOG.debug("OttOrderActivityDaoImpl : retrieveOrderTrackingActivityDetails : " + "Record found for lastSuccessRun " + lastSuccessRun + " in OTT_ORDER_ACTIVITY_VIEW table"); } } LOG.debug("OttOrderActivityDaoImpl : retrieveOrderTrackingActivityDetails : " + "Record not found for lastSuccessRun " + lastSuccessRun + " in OTT_ORDER_ACTIVITY_VIEW table"); LOG.info("retrieveOrderTrackingActivityDetails Method ----------- ENDS"); return ottOrderActivityList; }