Hi,
I have an SQL query that I would like to convert into a criteria to use it into my persistancy layer.
That's the query :
Code:
select last_name
from member
where
member.end_date > SYSDATE
group by member.last_name
having count(member.last_name) >1;
I already try a lot a combinations, but there is no result that would be good for me ... This is my code :
Code:
Criteria criteria = getSession(false).createCriteria(Member.ENTITY_NAME);
criteria.setProjection(Projections.projectionList()
.add(Projections.groupProperty("lastName"))
.add(Projections.count("lastName").as("cptLastName"))
);
criteria.add(Restrictions.ge("endDate", now))
.add(Restrictions.le("startDate", now))
//.add(Restrictions.gt("cptLastName", new Integer(1)))[/color]
.addOrder(Order.asc("lastName"))
;
With writing it with the comment line, I have an objects list that contains the name and the number of times that the name appears in the database. But when i would like to decomment it, this the error :
java.sql.SQLException: ORA-00904: "Y1_": invalid identifier
I think I'm not far of the solution but is there anabody to help me ?
If you have questions, don't hesitate to tell me.
Thanks in advance