# HG changeset patch # User Sascha L. Teichmann # Date 1342104683 0 # Node ID 51f037483071f2984fb9e1a6cf9eb3a85c5eb27e # Parent 509af52db23b26d50918d17df80bed6a55423aa3 Backend: Strategy to directly transform native SQL results into Maps. flys-backend/trunk@4955 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 509af52db23b -r 51f037483071 flys-backend/ChangeLog --- a/flys-backend/ChangeLog Thu Jul 12 09:01:43 2012 +0000 +++ b/flys-backend/ChangeLog Thu Jul 12 14:51:23 2012 +0000 @@ -1,3 +1,8 @@ +2012-07-12 Sascha L. Teichmann + + * src/main/java/de/intevation/hibernate/MapResultTransformer.java: + Strategy to directly transform native SQL results into Maps. + 2012-07-11 Sascha L. Teichmann Fix for flys/issue359 diff -r 509af52db23b -r 51f037483071 flys-backend/src/main/java/de/intevation/hibernate/MapResultTransformer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/hibernate/MapResultTransformer.java Thu Jul 12 14:51:23 2012 +0000 @@ -0,0 +1,23 @@ +package de.intevation.hibernate; + +import java.util.HashMap; +import java.util.Map; + +import org.hibernate.transform.BasicTransformerAdapter; + +public class MapResultTransformer +extends BasicTransformerAdapter +{ + public MapResultTransformer() { + } + + @Override + public Object transformTuple(Object [] tuple, String [] aliases) { + Map map = new HashMap(); + for (int i = 0; i < tuple.length; ++i) { + map.put(aliases[i], tuple[i]); + } + return map; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :