annotate flys-backend/src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java @ 760:c8a2fbc612be

Register the backend model. flys-backend/trunk@2108 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 14 Jun 2011 13:31:34 +0000
parents d37ccb04ab5d
children 8076f6a689d0
rev   line source
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.backend;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
3 import de.intevation.artifacts.common.utils.Config;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
5 import java.util.Properties;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7 import org.hibernate.SessionFactory;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 import org.hibernate.cfg.Configuration;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10 import org.hibernate.cfg.Environment;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 import de.intevation.flys.model.Annotation;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13 import de.intevation.flys.model.Attribute;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14 import de.intevation.flys.model.DischargeTable;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15 import de.intevation.flys.model.DischargeTableValue;
760
c8a2fbc612be Register the backend model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 464
diff changeset
16 import de.intevation.flys.model.Edge;
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 import de.intevation.flys.model.Gauge;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18 import de.intevation.flys.model.MainValueType;
189
bc3747a371cc First part of parsing main values.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 179
diff changeset
19 import de.intevation.flys.model.NamedMainValue;
bc3747a371cc First part of parsing main values.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 179
diff changeset
20 import de.intevation.flys.model.MainValue;
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21 import de.intevation.flys.model.Position;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 import de.intevation.flys.model.Range;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23 import de.intevation.flys.model.River;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24 import de.intevation.flys.model.TimeInterval;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 import de.intevation.flys.model.WstColumn;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26 import de.intevation.flys.model.WstColumnQRange;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 import de.intevation.flys.model.WstColumnValue;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 import de.intevation.flys.model.Wst;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 import de.intevation.flys.model.WstQRange;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31 import org.apache.log4j.Logger;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 public final class SessionFactoryProvider
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 {
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35 private static Logger log = Logger.getLogger(SessionFactoryProvider.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 public static final String XPATH_USER =
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 "/artifact-database/backend-database/user/text()";
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 public static final String XPATH_PASSWORD =
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 "/artifact-database/backend-database/password/text()";
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 public static final String XPATH_DIALECT =
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 "/artifact-database/backend-database/dialect/text()";
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 public static final String XPATH_DRIVER =
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47 "/artifact-database/backend-database/driver/text()";
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 public static final String XPATH_URL =
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50 "/artifact-database/backend-database/url/text()";
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51
179
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
52 public static final String DEFAULT_USER =
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
53 System.getProperty("flys.backend.user", "flys");
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
54
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
55 public static final String DEFAULT_PASSWORD =
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
56 System.getProperty("flys.backend.password", "flys");
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
57
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
58 public static final String DEFAULT_DIALECT =
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
59 System.getProperty(
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
60 "flys.backend.dialect",
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
61 "org.hibernate.dialect.PostgreSQLDialect");
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63 public static final String DEFAULT_DRIVER =
179
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
64 System.getProperty(
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
65 "flys.backend.driver",
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
66 "org.postgresql.Driver");
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
67
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
68 public static final String DEFAULT_URL =
179
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
69 System.getProperty(
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
70 "flys.backend.url",
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
71 "jdbc:postgresql://localhost:5432/flys");
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
72
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
73 private static SessionFactory sessionFactory;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
74
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
75 private SessionFactoryProvider() {
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
76 }
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
77
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
78 public static synchronized SessionFactory getSessionFactory() {
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
79 if (sessionFactory == null) {
178
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
80 String user =
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
81 Config.getStringXPath(XPATH_USER, DEFAULT_USER);
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
82 String password =
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
83 Config.getStringXPath(XPATH_PASSWORD, DEFAULT_PASSWORD);
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
84 String dialect =
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
85 Config.getStringXPath(XPATH_DIALECT, DEFAULT_DIALECT);
464
d37ccb04ab5d Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 189
diff changeset
86 String driver =
178
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
87 Config.getStringXPath(XPATH_DRIVER, DEFAULT_DRIVER);
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
88 String url =
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
89 Config.getStringXPath(XPATH_URL, DEFAULT_URL);
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
90
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
91 sessionFactory = createSessionFactory(
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
92 user, password, dialect, driver, url);
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
93 }
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
94 return sessionFactory;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
95 }
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
96
179
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
97 public static SessionFactory createSessionFactory() {
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
98 return createSessionFactory(
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
99 DEFAULT_USER,
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
100 DEFAULT_PASSWORD,
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
101 DEFAULT_DIALECT,
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
102 DEFAULT_DRIVER,
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
103 DEFAULT_URL);
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
104 }
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
105
178
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
106 public static SessionFactory createSessionFactory(
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
107 String user,
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
108 String password,
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
109 String dialect,
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
110 String driver,
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
111 String url
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
112 ) {
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
113 Configuration cfg = new Configuration();
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
114
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
115 // TODO: Use package reflection here.
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
116 cfg.addAnnotatedClass(Annotation.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
117 cfg.addAnnotatedClass(Attribute.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
118 cfg.addAnnotatedClass(DischargeTable.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
119 cfg.addAnnotatedClass(DischargeTableValue.class);
760
c8a2fbc612be Register the backend model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 464
diff changeset
120 cfg.addAnnotatedClass(Edge.class);
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
121 cfg.addAnnotatedClass(Gauge.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
122 cfg.addAnnotatedClass(MainValueType.class);
189
bc3747a371cc First part of parsing main values.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 179
diff changeset
123 cfg.addAnnotatedClass(NamedMainValue.class);
bc3747a371cc First part of parsing main values.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 179
diff changeset
124 cfg.addAnnotatedClass(MainValue.class);
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
125 cfg.addAnnotatedClass(Position.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
126 cfg.addAnnotatedClass(Range.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
127 cfg.addAnnotatedClass(River.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
128 cfg.addAnnotatedClass(TimeInterval.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
129 cfg.addAnnotatedClass(WstColumn.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
130 cfg.addAnnotatedClass(WstColumnQRange.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
131 cfg.addAnnotatedClass(WstColumnValue.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
132 cfg.addAnnotatedClass(Wst.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
133 cfg.addAnnotatedClass(WstQRange.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
134
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
135 if (log.isDebugEnabled()) {
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
136 log.debug("user: " + user);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
137 log.debug("dialect: " + dialect);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
138 log.debug("driver: " + driver);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
139 log.debug("url: " + url);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
140 }
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
141
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
142 Properties props = new Properties();
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
143
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
144 // We rely on our own connection pool
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
145 props.setProperty(
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
146 "hibernate.connection.provider_class",
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
147 "org.hibernate.connection.DBCPConnectionProvider");
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
148
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
149 props.setProperty(Environment.DIALECT, dialect);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
150 props.setProperty(Environment.USER, user);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
151 props.setProperty(Environment.PASS, password);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
152 props.setProperty(Environment.DRIVER, driver);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
153 props.setProperty(Environment.URL, url);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
154
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
155 cfg.mergeProperties(props);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
156
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
157 return cfg.buildSessionFactory();
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
158 }
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
159 }
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
160 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org