public GtfsMutableRelationalDao getDao() { if (_dao == null) _dao = new HibernateGtfsRelationalDaoImpl(_sessionFactory); return _dao; }
public HibernateGtfsRelationalDaoImpl(SessionFactory sessionFactory) { setSessionFactory(sessionFactory); }
@Override public void run() { try { HibernateGtfsRelationalDaoImpl store = new HibernateGtfsRelationalDaoImpl(); store.setSessionFactory(_sessionFactory); GtfsReadingSupport.readGtfsIntoStore(_applicationContext, store); } catch (Throwable ex) { throw new IllegalStateException("error loading gtfs", ex); } }
private TripIdentifier getTripAsIdentifier(final Trip trip) { String routeName = trip.getRoute().getId().getId(); int startTime = -1; String startStop; /** * This is WAY faster if we are working in hibernate, in that we don't need * to look up EVERY StopTime for a Trip, along with the Stop objects for * those StopTimes. Instead, we just grab the first departure time. */ if (gtfsDao instanceof HibernateGtfsRelationalDaoImpl) { HibernateGtfsRelationalDaoImpl dao = (HibernateGtfsRelationalDaoImpl) gtfsDao; List<?> rows = (List<?>) dao.execute(new HibernateOperation() { @Override public Object doInHibernate(Session session) throws HibernateException, SQLException { Query query = session.createQuery("SELECT st.departureTime, st.stop.id.id FROM StopTime st WHERE st.trip = :trip AND st.departureTime >= 0 ORDER BY st.departureTime ASC LIMIT 1"); query.setParameter("trip", trip); return query.list(); } }); Object[] values = (Object[]) rows.get(0); startTime = ((Integer) values[0]); startStop = (String) values[1]; } else { StopTime stopTime = gtfsDao.getStopTimesForTrip(trip).get(0); startTime = stopTime.getDepartureTime(); startStop = stopTime.getStop().getId().getId(); } return new TripIdentifier(routeName, startTime, startStop); }
public GtfsMutableRelationalDao getDao() { if (_dao == null) _dao = new HibernateGtfsRelationalDaoImpl(_sessionFactory); return _dao; }
public HibernateGtfsRelationalDaoImpl(SessionFactory sessionFactory) { setSessionFactory(sessionFactory); }