annotate backend/src/main/java/de/intevation/hibernate/MapResultTransformer.java @ 5844:4dd33b86dc61

Added header to river backend.
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 26 Apr 2013 08:25:41 +0200
parents 5aa05a7a34b7
children
rev   line source
5844
4dd33b86dc61 Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4dd33b86dc61 Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4dd33b86dc61 Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
4dd33b86dc61 Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
4dd33b86dc61 Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
4dd33b86dc61 Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
6 * documentation coming with Dive4Elements River for details.
4dd33b86dc61 Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4dd33b86dc61 Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5829
18619c1e7c2a Repaired internal references.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3342
diff changeset
9 package org.dive4elements.hibernate;
3341
51f037483071 Backend: Strategy to directly transform native SQL results into Maps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10
51f037483071 Backend: Strategy to directly transform native SQL results into Maps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11 import java.util.HashMap;
51f037483071 Backend: Strategy to directly transform native SQL results into Maps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 import java.util.Map;
51f037483071 Backend: Strategy to directly transform native SQL results into Maps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13
51f037483071 Backend: Strategy to directly transform native SQL results into Maps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14 import org.hibernate.transform.BasicTransformerAdapter;
51f037483071 Backend: Strategy to directly transform native SQL results into Maps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15
51f037483071 Backend: Strategy to directly transform native SQL results into Maps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16 public class MapResultTransformer
51f037483071 Backend: Strategy to directly transform native SQL results into Maps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 extends BasicTransformerAdapter
51f037483071 Backend: Strategy to directly transform native SQL results into Maps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18 {
3342
3d3e40d9d6d7 MapResultTransformer: Added static INSTANCE because its stateless.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3341
diff changeset
19 public static final MapResultTransformer INSTANCE =
3d3e40d9d6d7 MapResultTransformer: Added static INSTANCE because its stateless.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3341
diff changeset
20 new MapResultTransformer();
3d3e40d9d6d7 MapResultTransformer: Added static INSTANCE because its stateless.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3341
diff changeset
21
3341
51f037483071 Backend: Strategy to directly transform native SQL results into Maps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 public MapResultTransformer() {
51f037483071 Backend: Strategy to directly transform native SQL results into Maps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23 }
51f037483071 Backend: Strategy to directly transform native SQL results into Maps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24
51f037483071 Backend: Strategy to directly transform native SQL results into Maps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 @Override
51f037483071 Backend: Strategy to directly transform native SQL results into Maps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26 public Object transformTuple(Object [] tuple, String [] aliases) {
51f037483071 Backend: Strategy to directly transform native SQL results into Maps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 Map<String, Object> map = new HashMap<String, Object>();
51f037483071 Backend: Strategy to directly transform native SQL results into Maps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 for (int i = 0; i < tuple.length; ++i) {
51f037483071 Backend: Strategy to directly transform native SQL results into Maps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 map.put(aliases[i], tuple[i]);
51f037483071 Backend: Strategy to directly transform native SQL results into Maps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 }
51f037483071 Backend: Strategy to directly transform native SQL results into Maps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31 return map;
51f037483071 Backend: Strategy to directly transform native SQL results into Maps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 }
51f037483071 Backend: Strategy to directly transform native SQL results into Maps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 }
51f037483071 Backend: Strategy to directly transform native SQL results into Maps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org