Support custom row-mapping projections
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Querydsl |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
I do not use DTO generation. For projecting query results into domain objects, I normally use either QBean or ConstructorExpr
In these cases, I'd like to be able to implement something like Spring's RowMapper interface for manual projection logic, only instead of ResultSet it should be strongly typed just like everything else in Querydsl, so that I could write things like:
QUserGroup ug = QUserGroup.
from(ug).list(new MappingProjecti
protected UserGroup map(Tuple row, QUserGroup columns) {
UserGroup group = new UserGroup();
return group;
}
});
I've attached a rather compact working prototype of MappingProjection - which is a FactoryExpression based on QTuple. Maybe I'm missing something, but I couldn't find an easier way to do that in Querydsl 2.2.0-beta4.
If you think it would make sense to include it into Querydsl (in one form or another), please do so. Also I would be very much interested to hear your opinion: is it the best way to go or do you see alternative solutions.