Hi all,
I'm quite desperate using criteria queries. I just want to do something like this:
Code:
select a.name, a.description
from t_elem a, t_val b
where
a.elem_id = b.elem_id and
b.date >= TO_DATE('20071109','YYYYMMDD')
It's a simple join, that I cannot make with criteria. I've tried two possibilites, but doesn't work:
First
Code:
List listaElements = HibernateUtil.getCurrentSession().createCriteria(ElementoValorVO.class).setProjection(
Projections.distinct(Projections.projectionList().add(Projections.property(ConstantesHibernate.ELEMENTO_ID))))
.add(Restrictions.ge(ConstantesHibernate.FECHA_ALTA, criteriosTipologia.getFechaActualizacion()))
.list();
Criteria criteria = HibernateUtil.getCurrentSession().createCriteria(PersonaResumenVO.class)
.setFetchMode("listaElements",FetchMode.JOIN);
This seems to work like a left join.
The second try was like the first, but the join was:
Code:
Criteria criteria = HibernateUtil.getCurrentSession().createCriteria(ElementoVO.class)
.createCriteria("listaElementos", CriteriaSpecification.INNER_JOIN);
Of course, this one crashes and throws an Exception telling me 'could not resolver property: listaElementos', which is just a List and not an element of the class to join.
How can I make that query using criteria, thanks!!
Ups... I forgot to tell that I'm using hibernate 3, and sorry for my english ;)