Mercurial > dive4elements > river
diff flys-backend/src/main/java/de/intevation/hibernate/MapResultTransformer.java @ 3689:c938e568c4a2 2.9
merged flys-backend/2.9
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:44 +0200 |
parents | 3d3e40d9d6d7 |
children | 18619c1e7c2a |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/hibernate/MapResultTransformer.java Fri Sep 28 12:14:44 2012 +0200 @@ -0,0 +1,26 @@ +package de.intevation.hibernate; + +import java.util.HashMap; +import java.util.Map; + +import org.hibernate.transform.BasicTransformerAdapter; + +public class MapResultTransformer +extends BasicTransformerAdapter +{ + public static final MapResultTransformer INSTANCE = + new MapResultTransformer(); + + public MapResultTransformer() { + } + + @Override + public Object transformTuple(Object [] tuple, String [] aliases) { + Map<String, Object> map = new HashMap<String, Object>(); + 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 :