The title says it all, here's the use case:
I have a scalar Criteria query, like this:
Code:
class Result {
public String pk;
public BigInteger count; // Here comes trouble.
}
Criteria cr =
getCurrentSession().createCriteria(Entity.class)
.setProjection(Projections.projectionList()
.add(Projections.groupProperty("entity_pk"), "pk") // Returns proper String type
.add(Projections.rowCount()) // returns Long instead of BigDecimal
).setResultTransformer(Transformers.aliasToBean(Result.class));
I'm having trouble with the rowCount projection: it returns a Long, but the member variable is a BigInteger so the aliasToBean transformer will fail with an incompatible type.
I could roll my own transformer (using Apache Commons BeanUtils, which do this kind of conversion automatically), but I'd prefer to make the Criteria return the wanted type right away.