Hi guys,

On my trip home i bored myself with implementing support for resulttransformer on HQL/SQL.

I reused the ResultTransformer interface since having a different interface felt redundant (even though one of the methods won't be used from HQL/SQL)

This means that on my h3.2 impl you can do stuff like:

returns value classes with setter injection instead of constructor injection via "select new" session.createQuery( "select an.description as description, an.bodyWeight as bodyWeight from Animal an" ) .setResultTransformer(new AliasToBeanResultTransformer(Animal.class)).list();

returns a map/list/value class from any sql (including stored procedures etc.) session.createSQLQuery( "select * from Employment e, Employeer emp where e.eid=emp.id" ).addEntity(Employment.class).addJoin(Employer.class)
                .setResultTransformer(Transformers.ALIAS_TO_MAP).list();
(map will have "Employment" and "Employer" key/elements)

session.createSQLQuery( "select * from Employment" )
                .setResultTransformer(Transformers.ALIAS_TO_MAP).list();
(map will have key per column to the corresponding value)

I have some outstanding issues:

Is Query.setResultTransformer() the proper interface ? A more intelligent setResultClass method would be much more readable imo, e.g. query.setResultClass(Map.class), query.setResultClass(Animal.class), etc. (maybe have both ?)

Decide what should happen if the query string already contains "select new list/map/constructorbean..."; currently the custom resulttransformer is ignored in this case.

Should it work with QueryCache ? If yes, we need to stop performing the transformation on stuff we put in the querycache ...

Make the old query translator throw an exception if user try to set a resulttransformer.

Let me know what you think.

--
--
Max Rydahl Andersen
callto://max.rydahl.andersen

Hibernate
[EMAIL PROTECTED]
http://hibernate.org

JBoss Inc
[EMAIL PROTECTED]


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
hibernate-devel mailing list
hibernate-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to