Exemple #1
0
 @SuppressWarnings("unchecked")
 @Override
 public List<Color> getAllColors() {
   Session session = dbHandler.getSessionFactory().openSession();
   String queryString = "from Color c order by c.price";
   Query query = session.createQuery(queryString);
   List<Color> cols = (List<Color>) query.list();
   session.close();
   return cols;
 }
Exemple #2
0
 @SuppressWarnings("unchecked")
 @Override
 public List<CarModel> getAllCarModels() {
   Session session = dbHandler.getSessionFactory().openSession();
   String queryString = "from CarModel m order by m.price";
   Query query = session.createQuery(queryString);
   List<CarModel> models = (List<CarModel>) query.list();
   session.close();
   return models;
 }
Exemple #3
0
 @Override
 public Color getColor(String name) {
   Session session = dbHandler.getSessionFactory().openSession();
   String queryString = "from Color where name = :name";
   Query query = session.createQuery(queryString);
   query.setParameter("name", name);
   Color c = (Color) query.uniqueResult();
   session.close();
   return c;
 }
Exemple #4
0
 @Override
 public CarModel getCarModel(String name) {
   Session session = dbHandler.getSessionFactory().openSession();
   String queryString = "from CarModel where name = :name";
   Query query = session.createQuery(queryString);
   query.setParameter("name", name);
   CarModel m = (CarModel) query.uniqueResult();
   session.close();
   return m;
 }