A google search on Transformer usage shows several sites that explain how to use it.
For example:
http://relation.to/2133.lacehttp://prasadmarrapu.blogspot.com/2008/07/result-transformers-in-hibernate.htmlwhich nicely fill in some gaps in documentation.
However all these examples use inline SQL (Session.createSQLQuery()) rather than named SQL queries
(session.getNamedQuery()). Even after casting the result of the latter to a SQLQuery (the cast succeeds), if addScalar() is called on the SQLQuery, an UnsupportedOperationException is thrown on AbstractList.add() (which that method always throws if invoked). It appears that there might be some magic combination of <resultset> <return-scalar> or other mapping-file elements that would prevent this from happening, but I wasn't able to ferret it out, and fell back to using createSQLQuery() on the same SQL, which does not have the problem.
I think this is probably a bug. Is there a workaround?