@Override public Lek getLekById(int id) { Session session = this.sessionFactory.getCurrentSession(); Lek lek = (Lek) session.load(Lek.class, new Integer(id)); lek.getChorobas().size(); return lek; }
@SuppressWarnings("unchecked") @Override public Map<Lek, List<Choroba>> listLekiZchorobami() { Session session = this.sessionFactory.getCurrentSession(); List<Lek> leki = session.createQuery("from lek ").list(); leki.size(); Map<Lek, List<Choroba>> lekiChoroby = new HashMap<Lek, List<Choroba>>(); for (Lek lek : leki) { List<Choroba> choroby = (List<Choroba>) lek.getChorobas(); lekiChoroby.put(lek, choroby); } return lekiChoroby; }