Package org.hibernate.criterion

Examples of org.hibernate.criterion.DetachedCriteria


  }

  public Trip searchTrip(Trip trip) {
    String TRIP_ALIAS = "trip";
    DetachedCriteria query = DetachedCriteria.forClass(Trip.class, TRIP_ALIAS);
    buildFlightCriteria(trip.getArrival(), query, TRIP_ALIAS, "arrival");
    buildFlightCriteria(trip.getDeparture(), query, TRIP_ALIAS, "departure");
    return (Trip) query.getExecutableCriteria(currentSession()).uniqueResult();
  }
View Full Code Here


  }

  private void buildFlightCriteria(Flight sample, DetachedCriteria query,
      String TRIP_ALIAS, String FLIGHT_ALIAS) {

    DetachedCriteria flight = query.createCriteria(TRIP_ALIAS + "."
        + FLIGHT_ALIAS, FLIGHT_ALIAS, JoinType.LEFT_OUTER_JOIN);

    if (sample.getDate() != null)
      flight.add(Property.forName("date").eq((sample.getDate())));
    flight.add(Property.forName("operator").eq((sample.getOperator())));

    DetachedCriteria originAirport = query.createCriteria(FLIGHT_ALIAS
        + ".origin", JoinType.LEFT_OUTER_JOIN);
    originAirport.add(Property.forName("iataCode").eq(
        sample.getOrigin().getIataCode()));

    DetachedCriteria destinationAirport = query.createCriteria(FLIGHT_ALIAS
        + ".destination", JoinType.LEFT_OUTER_JOIN);
    destinationAirport.add(Property.forName("iataCode").eq(
        sample.getDestination().getIataCode()));

  }
View Full Code Here

    trip = trip.clone();
    trip.getArrival().setDate(null);
    trip.getDeparture().setDate(null);

    String TRIP_ALIAS = "trip";
    DetachedCriteria query = DetachedCriteria.forClass(Trip.class, TRIP_ALIAS);
    buildFlightCriteria(trip.getArrival(), query, TRIP_ALIAS, "arrival");
    buildFlightCriteria(trip.getDeparture(), query, TRIP_ALIAS, "departure");
    List<Trip> list = query.getExecutableCriteria(currentSession()).list();
    return list;
  }
View Full Code Here

   */
  @Transactional
  public Trip getNextElement(String operator) {

    // criteri x trip
    DetachedCriteria query = DetachedCriteria.forClass(Trip.class, "trip");
    query.add(Restrictions.isNull("starProcessingDate"));

    // criteri per departureFlight
    DetachedCriteria departureFlight = query.createCriteria("trip.departure",
        JoinType.LEFT_OUTER_JOIN);
    departureFlight.add(Property.forName("operator").eq(operator));

    // criteri per arrivalFlight
    DetachedCriteria arrivalFlight = query.createCriteria("trip.arrival",
        JoinType.LEFT_OUTER_JOIN);
    arrivalFlight.add(Property.forName("operator").eq(operator));

    List<Trip> list = tripRepository.list(query, 1);
    if (CollectionUtils.isEmpty(list))
      return null;

View Full Code Here

  /**
   * GET UNPROCESSED ELEMENTS
   */
  @Transactional
  public List<Trip> getUnprocessedElements() {
    DetachedCriteria query = DetachedCriteria.forClass(Trip.class, "trip");
    query.add(Restrictions.isNull("starProcessingDate"));
    return tripRepository.list(query, -1);
  }
View Full Code Here

    add(sample);
    return sample;
  }

  public Flight searchFlight(Flight flight) {
    DetachedCriteria query = DetachedCriteria.forClass(Flight.class, "flight");
    DetachedCriteria origin = query.createCriteria("flight.origin", "origin",
        JoinType.LEFT_OUTER_JOIN);
    DetachedCriteria destination = query.createCriteria("flight.destination",
        "destination", JoinType.LEFT_OUTER_JOIN);
    origin.add(Property.forName("iataCode")
        .eq(flight.getOrigin().getIataCode()));
    destination.add(Property.forName("iataCode").eq(
        flight.getDestination().getIataCode()));
    query.add(Property.forName("date").eq(flight.getDate()));
    query.add(Property.forName("operator").eq(flight.getOperator()));
    return (Flight) query.getExecutableCriteria(currentSession())
        .uniqueResult();
View Full Code Here

    return (User) getHibernateTemplate().save(user);
  }

  @SuppressWarnings("unchecked")
  public User findUser(String name, String password) {
    DetachedCriteria criteria = DetachedCriteria.forClass(User.class);
    criteria.add(Restrictions.and(Restrictions.eq("name", name),
        Restrictions.eq("password", password)));
    List<User> users = getHibernateTemplate().findByCriteria(criteria);
    if (users.isEmpty())
      return null;
    else
View Full Code Here

    getHibernateTemplate().saveOrUpdate(signature);
  }

  @Override
  public Signature findSignature(int person) {
    DetachedCriteria criteria = DetachedCriteria.forClass(Signature.class);
    criteria.add(Restrictions.eq("person", person));
    List<Signature> signatures = getHibernateTemplate().findByCriteria(
        criteria);
    if (signatures.isEmpty())
      return null;
    else
View Full Code Here

    getHibernateTemplate().saveOrUpdate(properties);
  }

  @Override
  public List<Properties> findProperties(int user, boolean value) {
    DetachedCriteria criteria = DetachedCriteria.forClass(Properties.class);
    criteria.add(Restrictions.and(Restrictions.eq("user", user),
        Restrictions.eq("value", value)));
    List<Properties> properties = getHibernateTemplate().findByCriteria(criteria);
    if (properties.isEmpty())
      return null;
    else
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  @Override
  public List<DictRoles> findDictRoles(String name) {
    DetachedCriteria criteria = DetachedCriteria.forClass(DictRoles.class);
    criteria.add(Restrictions.eq("name", name));
    List<DictRoles> roles = getHibernateTemplate().findByCriteria(criteria);
    if (roles.isEmpty())
      return null;
    else
      return roles;
View Full Code Here

TOP

Related Classes of org.hibernate.criterion.DetachedCriteria

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.