List of usage examples for org.hibernate Query list
List<R> list();
From source file:at.gv.egovernment.moa.id.storage.DBExceptionStoreImpl.java
License:EUPL
@SuppressWarnings("rawtypes") private ExceptionStore searchInDatabase(String id) throws MOADatabaseException { MiscUtil.assertNotNull(id, "exceptionID"); Logger.trace("Getting Exception with ID " + id + " from database."); Session session = MOASessionDBUtils.getCurrentSession(); List result;// w w w. j a v a2 s . c o m synchronized (session) { session.beginTransaction(); Query query = session.getNamedQuery("getExceptionWithID"); query.setParameter("id", id); result = query.list(); //send transaction session.getTransaction().commit(); } Logger.trace("Found entries: " + result.size()); //Assertion requires an unique artifact if (result.size() != 1) { Logger.trace("No entries found."); throw new MOADatabaseException("No Exception found with ID " + id); } return (ExceptionStore) result.get(0); }
From source file:at.thinkingco2.databasemanager.JourneyAccess.java
/** * This Function returns a list of JourneyBeans, which have no current drive * (JounreyBean which searches a lift)./*from w w w . j ava 2 s. com*/ * * @return a List of JounreyBean */ @SuppressWarnings("unchecked") public List<JourneyBean> getJourneysWithoutDriver() { Session session = getSession(); List<JourneyBean> list = null; Query q = null; q = session.createQuery("FROM JourneyBean WHERE licenseNumber IS NULL"); list = q.list(); session.close(); return list; }
From source file:at.thinkingco2.databasemanager.JourneyAccess.java
/** * This Function returns a list of JourneyBeans, which have a current driver * //from ww w. j a v a2s . co m * @return a List of JounreyBeans */ @SuppressWarnings("unchecked") public List<JourneyBean> getJourneysWithDriver() { Session session = getSession(); List<JourneyBean> list = null; Query q = null; q = session.createQuery("FROM JourneyBean WHERE licenseNumber NOT NULL"); list = q.list(); session.close(); return list; }
From source file:at.thinkingco2.databasemanager.JourneyAccess.java
/** * This function returns the Number of used Seats in a given Route * /* w ww. j a v a 2s . c o m*/ * @param routeId * The routeId * @return Number of used Seats */ @SuppressWarnings("unchecked") public Integer getUsedSeats(Integer routeId) { Session session = getSession(); List<JourneyBean> journeyList = null; Integer seats = 0; Query q = null; q = session.createQuery("FROM JourneyBean WHERE routeId = :routeId"); q.setParameter("routeId", routeId); journeyList = q.list(); for (JourneyBean journey : journeyList) { seats += journey.getChildren().size(); } session.close(); return seats + 1; // +1 = + parent }
From source file:at.thinkingco2.databasemanager.JourneyAccess.java
@SuppressWarnings("unchecked") public List<JourneyBean> getJourneysByRouteID(Integer routeId) { Session session = getSession();//from w w w .ja v a 2 s . c o m List<JourneyBean> list = null; Query q = session.createQuery("FROM JourneyBean WHERE routeId = :routeId"); q.setParameter("routeId", routeId); list = q.list(); session.close(); return list; }
From source file:at.treedb.db.hibernate.DAOhibernate.java
License:Open Source License
@Override public List<?> query(String query, HashMap<String, Object> map) { Query q; if (isStatelessSession) { q = statelessSession.createQuery(query); } else {/*from w w w .j a v a 2s.c om*/ q = session.createQuery(query); } if (map != null) { Iterator<String> iter = map.keySet().iterator(); while (iter.hasNext()) { String key = iter.next(); Object o = map.get(key); q.setParameter(key, o); } } return q.list(); }
From source file:at.treedb.db.hibernate.DAOhibernate.java
License:Open Source License
@Override public List<?> query(String query, int start, int length, HashMap<String, Object> map) { Query q; if (isStatelessSession) { q = statelessSession.createQuery(query); } else {/*from w w w . j av a 2 s.com*/ q = session.createQuery(query); } if (map != null) { Iterator<String> iter = map.keySet().iterator(); while (iter.hasNext()) { String key = iter.next(); Object o = map.get(key); q.setParameter(key, o); } } q.setFirstResult(start); q.setMaxResults(length); return q.list(); }
From source file:attendance.Attendance_DAO.java
@SuppressWarnings("unchecked") public List<Attendance> list() { List<Attendance> attendancelist = null; try {// w w w. j a va 2s . co m Query q = session.createQuery("from Attendance"); attendancelist = q.list(); } catch (HibernateException he) { System.out.println(he); } // t.commit(); session.close(); return attendancelist; }
From source file:attendance.ui.AttendanceSystem.java
private void executeHQLQuery(String hql) { try {//from www. j ava 2s. c o m Session session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); Query q = session.createQuery(hql); List resultList = q.list(); displayResult(resultList); session.getTransaction().commit(); } catch (HibernateException he) { he.printStackTrace(); } }
From source file:au.com.nicta.ct.db.CtKeyValueProperties.java
License:Open Source License
public static CtProperties find(String key) { List results = null;/*from ww w. ja va 2s . c om*/ Session s = CtSession.Create(); try { s.beginTransaction(); Query q = query(key, s); results = q.list(); s.getTransaction().commit(); } catch (Exception e) { } finally { s.close(); } if (results == null) return null; if (results.size() < 1) return null; CtProperties p = (CtProperties) results.get(0); return p; }