/** * Gets the all buildings. * * @return the all buildings */ public List<Building> getAllBuildings() { Session session = HibernateUtil.getSession(); List<Building> buildings = null; try { buildings = session.createQuery("from Building").list(); } catch (HibernateException e) { logger.warn(e.getMessage()); } return buildings; }
/** * Gets the building by id. * * @param id the id * @return the building by id */ public Building getBuildingById(final int id) { Session session = HibernateUtil.getSession(); Building building = null; try { // session.createQuery("from Building").list(); building = (Building) session.load(Building.class, id); } catch (HibernateException e) { logger.warn(e.getMessage()); } return building; }
/** Instantiates a new building dao. */ public BuildingDAO() { HibernateUtil.beginTransaction(); }