comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/RiverFactory.java @ 132:8be4a837f20a

Added support for the flys backend and an example how to use it. flys-artifacts/trunk@1498 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 17 Mar 2011 11:46:43 +0000
parents 394b9580ceae
children e8dfe6ba2000
comparison
equal deleted inserted replaced
131:0bab3a39a474 132:8be4a837f20a
1 package de.intevation.flys.artifacts.model; 1 package de.intevation.flys.artifacts.model;
2 2
3 import java.util.ArrayList; 3
4 import java.util.List; 4 import java.util.List;
5 5
6 import de.intevation.flys.model.River;
7
8 import de.intevation.flys.backend.SessionFactoryProvider;
9
10 import org.hibernate.SessionFactory;
11 import org.hibernate.Session;
12 import org.hibernate.Query;
6 13
7 /** 14 /**
8 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> 15 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
9 */ 16 */
10 public class RiverFactory { 17 public class RiverFactory {
18 * Returns all rivers that were found in the backend. 25 * Returns all rivers that were found in the backend.
19 * 26 *
20 * @return all rivers. 27 * @return all rivers.
21 */ 28 */
22 public static List<River> getRivers() { 29 public static List<River> getRivers() {
23 List<River> rivers = new ArrayList<River>(); 30 SessionFactory sf = SessionFactoryProvider.getSessionFactory();
24 31 Session session = sf.openSession();
25 rivers.add(new River("Mosel")); 32 try {
26 rivers.add(new River("Saar")); 33 return (List<River>)session
27 34 .createQuery("from River order by name").list();
28 return rivers; 35 }
36 finally {
37 session.close();
38 }
29 } 39 }
30 } 40 }
31 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : 41 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org