Hi,
I'm having a strange behavior:
I'm using the Criteria API to retrieve rows from DB filtering by ID.
Code:
Destinatario dest = new Destinatario();
dest.setId(new Long(2));
Example ex = Example.create(dest);
Session session1 = HibernateUtil.getSession();
Transaction tx1 = session1.beginTransaction();
Criteria criteria = session1.createCriteria(Destinatario.class);
criteria.add(ex);
List lista = criteria.list();
for (Object object : lista) {
Destinatario destAux = (Destinatario) object;
System.out.println(destAux.getNome());
}
tx1.commit();
I'm getting this output:
Code:
Hibernate:
select
this_.id as id1_0_,
this_.nome as nome1_0_,
this_.ultima_requisicao as ultima3_1_0_
from
destinatario this_
where
(
1=1
)
Blue Sky
Luso
It's giving me all the rows from the table.
It should give me one single row where ID=2.
What am I doing wrong?
Any help will be much appreciated!
Irshad