List of usage examples for org.hibernate Session createNamedQuery
<T> org.hibernate.query.Query<T> createNamedQuery(String name, Class<T> resultType);
From source file:edu.usf.cutr.gtfsrtvalidator.api.resource.GtfsRtFeed.java
License:Open Source License
@GET @Path("/{id : \\d+}/summary/pagination/{currentPage: \\d+}/{rowsPerPage: \\d+}") @Produces(MediaType.APPLICATION_JSON)//from w w w . ja va2 s. c o m public Response getRtFeedSummaryDetails(@PathParam("id") int id, @PathParam("currentPage") int currentPage, @PathParam("rowsPerPage") int rowsPerPage) { List<ViewErrorSummaryModel> feedSummary; int fromRow = (currentPage - 1) * rowsPerPage; Session session = GTFSDB.InitSessionBeginTrans(); feedSummary = session.createNamedQuery("ErrorSummaryByrtfeedID", ViewErrorSummaryModel.class) .setParameter(0, id).setParameter(1, id).setFirstResult(fromRow).setMaxResults(rowsPerPage).list(); GTFSDB.commitAndCloseSession(session); for (ViewErrorSummaryModel viewErrorSummaryModel : feedSummary) { int index = feedSummary.indexOf(viewErrorSummaryModel); String formattedTimestamp = getDateFormat(viewErrorSummaryModel.getLastTime(), id); viewErrorSummaryModel.setFormattedTimestamp(formattedTimestamp); viewErrorSummaryModel.setTimeZone(agencyTimezone); } GenericEntity<List<ViewErrorSummaryModel>> feedList = new GenericEntity<List<ViewErrorSummaryModel>>( feedSummary) { }; return Response.ok(feedList).build(); }
From source file:edu.usf.cutr.gtfsrtvalidator.api.resource.GtfsRtFeed.java
License:Open Source License
@GET @Path("/{id : \\d+}/log/{toggledData: .*}/pagination/{currentPage: \\d+}/{rowsPerPage: \\d+}") @Produces(MediaType.APPLICATION_JSON)/* w ww .j a v a 2 s .co m*/ public Response getRtFeedLogDetails(@PathParam("id") int id, @PathParam("toggledData") String hideErrors, @PathParam("currentPage") int currentPage, @PathParam("rowsPerPage") int rowsPerPage) { List<ViewErrorLogModel> feedLog; String[] removeIds = hideErrors.split(","); // Getting the value of fromRow from the rowsPerPage and currentPage values. int fromRow = (currentPage - 1) * rowsPerPage; Session session = GTFSDB.InitSessionBeginTrans(); feedLog = session.createNamedQuery("ErrorLogByrtfeedID", ViewErrorLogModel.class).setParameter(0, id) .setParameter(1, id).setParameterList("errorIds", removeIds).setFirstResult(fromRow) .setMaxResults(rowsPerPage).list(); GTFSDB.commitAndCloseSession(session); for (ViewErrorLogModel viewErrorLogModel : feedLog) { String formattedTimestamp = getDateFormat(viewErrorLogModel.getOccurrence(), id); viewErrorLogModel.setFormattedTimestamp(formattedTimestamp); viewErrorLogModel.setTimeZone(agencyTimezone); } GenericEntity<List<ViewErrorLogModel>> feedList = new GenericEntity<List<ViewErrorLogModel>>(feedLog) { }; return Response.ok(feedList).build(); }
From source file:edu.usf.cutr.gtfsrtvalidator.api.resource.GtfsRtFeed.java
License:Open Source License
@GET @Path("/{id : \\d+}/feedIterations") @Produces(MediaType.APPLICATION_JSON)/*from www .j ava 2 s.c o m*/ public Response getFeedIterationsCount(@PathParam("id") int id) { ViewFeedIterationsCount iterationsCount; Session session = GTFSDB.InitSessionBeginTrans(); iterationsCount = (ViewFeedIterationsCount) session .createNamedQuery("feedIterationsCount", ViewFeedIterationsCount.class).setParameter(0, id) .uniqueResult(); GTFSDB.commitAndCloseSession(session); return Response.ok(iterationsCount).build(); }
From source file:edu.usf.cutr.gtfsrtvalidator.api.resource.GtfsRtFeed.java
License:Open Source License
@GET @Path("/{iterationId : \\d+}/feedMessage") @Produces(MediaType.APPLICATION_JSON)/*from w ww .java 2 s .co m*/ public String getFeedMessage(@PathParam("iterationId") int iterationId) { ViewFeedMessageModel feedMessageModel; Session session = GTFSDB.InitSessionBeginTrans(); feedMessageModel = session.createNamedQuery("feedMessageByIterationId", ViewFeedMessageModel.class) .setParameter(0, iterationId).uniqueResult(); GTFSDB.commitAndCloseSession(session); feedMessageModel.setJsonFeedMessage(feedMessageModel.getByteFeedMessage()); return feedMessageModel.getJsonFeedMessage(); }
From source file:edu.usf.cutr.gtfsrtvalidator.api.resource.GtfsRtFeed.java
License:Open Source License
@GET @Path("/{id : \\d+}/uniqueResponses") @Produces(MediaType.APPLICATION_JSON)/*from w ww. j a v a 2s .c om*/ public Response getFeedUniqueResponses(@PathParam("id") int id) { ViewFeedUniqueResponseCount uniqueResponseCount; Session session = GTFSDB.InitSessionBeginTrans(); uniqueResponseCount = (ViewFeedUniqueResponseCount) session .createNamedQuery("feedUniqueResponseCount", ViewFeedUniqueResponseCount.class).setParameter(0, id) .uniqueResult(); GTFSDB.commitAndCloseSession(session); return Response.ok(uniqueResponseCount).build(); }
From source file:edu.usf.cutr.gtfsrtvalidator.api.resource.GtfsRtFeed.java
License:Open Source License
@GET @Path("/{id : \\d+}/errorCount") @Produces(MediaType.APPLICATION_JSON)/*from w w w . jav a 2s. c o m*/ public Response getFeedErrorCount(@PathParam("id") int id) { List<ViewGtfsRtFeedErrorCountModel> viewGtfsRtFeedErrorCountModel; Session session = GTFSDB.InitSessionBeginTrans(); viewGtfsRtFeedErrorCountModel = session .createNamedQuery("feedErrorCount", ViewGtfsRtFeedErrorCountModel.class).setParameter(0, id).list(); GTFSDB.commitAndCloseSession(session); GenericEntity<List<ViewGtfsRtFeedErrorCountModel>> errorList = new GenericEntity<List<ViewGtfsRtFeedErrorCountModel>>( viewGtfsRtFeedErrorCountModel) { }; return Response.ok(errorList).build(); }
From source file:gov.ca.cwds.cals.persistence.dao.calsns.TrackingDao.java
private Query<Tracking> getTrackingQuery(String queryName) { Session session = this.getSessionFactory().getCurrentSession(); return session.createNamedQuery(queryName, Tracking.class); }
From source file:gov.ca.cwds.data.legacy.cms.dao.ClientDao.java
private Client findSingleFacility(String queryName, Consumer<Query<Client>> setParameters) { Session session = grabSession(); Class<Client> entityClass = getEntityClass(); Query<Client> query = session.createNamedQuery(entityClass.getSimpleName() + "." + queryName, entityClass); setParameters.accept(query);// w w w . ja v a2 s . c o m query.setMaxResults(1); Client client = null; try { client = query.getSingleResult(); } catch (NoResultException e) { LOG.debug(e.getMessage(), e); } return client; }
From source file:gov.ca.cwds.data.legacy.cms.dao.LicenseStatusDao.java
License:Open Source License
@Override public List<LicenseStatus> findAll() { Session session = this.grabSession(); final Query<LicenseStatus> query = session.createNamedQuery(LicenseStatus.NQ_ALL, LicenseStatus.class); ImmutableList.Builder<LicenseStatus> entities = new ImmutableList.Builder<>(); entities.addAll(query.list());//w w w .ja v a 2s .c o m return entities.build(); }
From source file:kievreclama.task.dao.impl.DepartmentDaoImpl.java
@Override @Transactional//w ww.j a va 2s . co m public List<Department> byList(String namedQery) { Session session = sessionFactory.getCurrentSession(); TypedQuery<Department> typedQuery = session.createNamedQuery(namedQery, Department.class); return typedQuery.getResultList(); }