Hi!
I have a subquery:
DetachedCriteria subquery =
DetachedCriteria.forClass(SemopsTransaction.class, "T");
subquery
.add(Restrictions.eq("paymentStatus",status)
.......
Criteria criteriaCount = subquery.getExecutableCriteria(sessionFactory.getCurrentSession());
criteriaCount.setProjection(Projections.countDistinct("idTransaction"));
int count = (Integer)criteriaCount.uniqueResult();
Affter count is queried I want to use the same subquery (with some modification) to get entries from the table (without any projection):
Criteria criteria = subquery.getExecutableCriteria(sessionFactory.getCurrentSession());
criteria .add(Property.forName("E.timestamp").in(subqueryGroup))
.setFetchMode("E", FetchMode.JOIN);
List<SemopsTransaction> list = criteria.list();
At the first time I want to get back only the count (it works) and with the second query (that use the same subquery) I need all columns from the table.
The problem is that if I set the count at the first query it will take part in the second query as well... I know If I add new projection to the second query I can avoid the count but I need all entries from the table and I don't want to specify each column separately for projection...
So How can I do with subquery + criteria:
first: select count(T) from <subquery>
second: select * from <subquery>
Thx,
topicfun
|