Search code examples
javasqlhibernatehql

HQL-Select from 2 tables


I am a beginner in Hibernate. I want to select data from two tables using hql. the problem is that the query gives me result if I select one object like this example:

(select d from eresa  e, dresa  d where  e.f_ideResa = d.eresa.f_ideResa and e.F_DATEFROM=:x)

but when i want to select multiples data from 2 two tables like this :

(select e.f_ideResa, d.F_PAXNAME from eresa as e, dresa as d where  e.f_ideResa = d.eresa.f_ideResa and e.F_DATEFROM=:x  ");)

it gives me error:

Etat HTTP 500 - java.lang.NumberFormatException..


Solution

  • I think I shoud to use arraylist instead list

    public List<eresa> getDetailparDateArrive(Date date) {
            // TODO Auto-generated method stub
            Session session=HibernateUtil.getSessionFactory().getCurrentSession();
            session.beginTransaction();
        //  Query req=session.createQuery("from eresa e inner join dresa d on e.f_ideResa = d.eresa.f_ideResa and e.F_DATEFROM=:x  ");
            Query req=session.createQuery("from eresa e, dresa d where e.F_DATEFROM=:x and e.f_ideResa = d.eresa.f_ideResa ");
            req.setParameter("x", date);
            return req.list();
        }