Exemplo n.º 1
0
 /**
  * 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;
 }
Exemplo n.º 2
0
 /**
  * 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;
 }