annotate flys-backend/src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java @ 2799:501f00e355eb

Added model class for 'floodmaps'. flys-backend/trunk@4129 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 08 Mar 2012 13:32:45 +0000
parents efe19e669092
children 3fdac7b43dac
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
2337
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
5 import java.lang.management.ManagementFactory;
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6 import java.util.Properties;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7
2337
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
8 import javax.management.InstanceAlreadyExistsException;
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
9 import javax.management.MalformedObjectNameException;
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
10 import javax.management.MBeanRegistrationException;
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
11 import javax.management.MBeanServer;
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
12 import javax.management.NotCompliantMBeanException;
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
13 import javax.management.ObjectName;
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
14
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15 import org.hibernate.SessionFactory;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16
2361
e9b0fd1de89d Made flys-backend compatible with oracle spatial.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2360
diff changeset
17 import org.hibernate.impl.SessionFactoryImpl;
e9b0fd1de89d Made flys-backend compatible with oracle spatial.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2360
diff changeset
18
2337
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
19 import org.hibernate.jmx.StatisticsService;
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
20
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21 import org.hibernate.cfg.Configuration;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 import org.hibernate.cfg.Environment;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24 import de.intevation.flys.model.Annotation;
763
8076f6a689d0 First part of flys/issue18
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 760
diff changeset
25 import de.intevation.flys.model.AnnotationType;
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26 import de.intevation.flys.model.Attribute;
1230
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1229
diff changeset
27 import de.intevation.flys.model.Building;
2364
efe19e669092 Added and registered a model Catchment for 'catchment' relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2363
diff changeset
28 import de.intevation.flys.model.Catchment;
1194
491892931761 Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1193
diff changeset
29 import de.intevation.flys.model.CrossSection;
1203
3c01bef43a98 Querprofile: Added a table to map the points to a given km.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1195
diff changeset
30 import de.intevation.flys.model.CrossSectionLine;
1194
491892931761 Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1193
diff changeset
31 import de.intevation.flys.model.CrossSectionPoint;
1230
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1229
diff changeset
32 import de.intevation.flys.model.CrossSectionTrack;
1236
324cb486db9f Added relation and hibernate classes for DGMs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1232
diff changeset
33 import de.intevation.flys.model.DGM;
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 import de.intevation.flys.model.DischargeTable;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35 import de.intevation.flys.model.DischargeTableValue;
760
c8a2fbc612be Register the backend model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 464
diff changeset
36 import de.intevation.flys.model.Edge;
1230
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1229
diff changeset
37 import de.intevation.flys.model.Fixpoint;
2799
501f00e355eb Added model class for 'floodmaps'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2364
diff changeset
38 import de.intevation.flys.model.Floodmaps;
1237
774dff3ee546 Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1236
diff changeset
39 import de.intevation.flys.model.Floodplain;
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 import de.intevation.flys.model.Gauge;
2363
a8f408fdf58c Added model for 'hws' relation and synced postgis with oracle spatial schema.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2362
diff changeset
41 import de.intevation.flys.model.Hws;
1210
31d8638760b1 New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1203
diff changeset
42 import de.intevation.flys.model.HYK;
31d8638760b1 New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1203
diff changeset
43 import de.intevation.flys.model.HYKEntry;
31d8638760b1 New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1203
diff changeset
44 import de.intevation.flys.model.HYKFormation;
31d8638760b1 New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1203
diff changeset
45 import de.intevation.flys.model.HYKFlowZoneType;
31d8638760b1 New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1203
diff changeset
46 import de.intevation.flys.model.HYKFlowZone;
1230
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1229
diff changeset
47 import de.intevation.flys.model.Line;
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 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
49 import de.intevation.flys.model.NamedMainValue;
bc3747a371cc First part of parsing main values.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 179
diff changeset
50 import de.intevation.flys.model.MainValue;
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51 import de.intevation.flys.model.Position;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 import de.intevation.flys.model.Range;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 import de.intevation.flys.model.River;
1230
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1229
diff changeset
54 import de.intevation.flys.model.RiverAxis;
2360
9df06b88c079 Added model class for relation 'river_axes_km'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2346
diff changeset
55 import de.intevation.flys.model.RiverAxisKm;
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 import de.intevation.flys.model.TimeInterval;
2346
f834b411ca57 Added db table, model class and importer stuff for units.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2337
diff changeset
57 import de.intevation.flys.model.Unit;
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58 import de.intevation.flys.model.WstColumn;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59 import de.intevation.flys.model.WstColumnQRange;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60 import de.intevation.flys.model.WstColumnValue;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61 import de.intevation.flys.model.Wst;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62 import de.intevation.flys.model.WstQRange;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
64 import org.apache.log4j.Logger;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66 public final class SessionFactoryProvider
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 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
69
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
70 public static final String XPATH_USER =
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
71 "/artifact-database/backend-database/user/text()";
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 public static final String XPATH_PASSWORD =
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
74 "/artifact-database/backend-database/password/text()";
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
75
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
76 public static final String XPATH_DIALECT =
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
77 "/artifact-database/backend-database/dialect/text()";
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
78
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
79 public static final String XPATH_DRIVER =
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
80 "/artifact-database/backend-database/driver/text()";
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
81
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
82 public static final String XPATH_URL =
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
83 "/artifact-database/backend-database/url/text()";
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
84
179
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
85 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
86 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
87
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
88 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
89 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
90
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
91 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
92 System.getProperty(
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
93 "flys.backend.dialect",
1232
3383e042a655 Reverted the default db dialect back PostgreSQL.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1230
diff changeset
94 "org.hibernate.dialect.PostgreSQLDialect");
176
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 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
97 System.getProperty(
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
98 "flys.backend.driver",
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
99 "org.postgresql.Driver");
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
100
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
101 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
102 System.getProperty(
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
103 "flys.backend.url",
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
104 "jdbc:postgresql://localhost:5432/flys");
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
105
2337
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
106 public static final boolean ENABLE_JMX =
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
107 Boolean.getBoolean("flys.backend.enablejmx");
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
108
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
109 private static SessionFactory sessionFactory;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
110
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
111 private SessionFactoryProvider() {
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
112 }
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
113
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
114 public static synchronized SessionFactory getSessionFactory() {
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
115 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
116 String user =
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
117 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
118 String password =
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
119 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
120 String dialect =
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
121 Config.getStringXPath(XPATH_DIALECT, DEFAULT_DIALECT);
464
d37ccb04ab5d Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 189
diff changeset
122 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
123 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
124 String url =
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
125 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
126
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
127 sessionFactory = createSessionFactory(
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
128 user, password, dialect, driver, url);
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
129 }
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
130 return sessionFactory;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
131 }
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
132
179
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
133 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
134 return createSessionFactory(
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
135 DEFAULT_USER,
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
136 DEFAULT_PASSWORD,
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
137 DEFAULT_DIALECT,
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
138 DEFAULT_DRIVER,
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
139 DEFAULT_URL);
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
140 }
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
141
178
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
142 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
143 String user,
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
144 String password,
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
145 String dialect,
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
146 String driver,
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
147 String url
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
148 ) {
1229
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
149 Configuration cfg = createConfiguration(
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
150 user, password, dialect, driver, url);
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
151
2337
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
152 SessionFactory factory = cfg.buildSessionFactory();
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
153
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
154 if (ENABLE_JMX) {
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
155 registerAsMBean(factory);
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
156 }
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
157 else {
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
158 log.info("No JMX support for hibernate.");
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
159 }
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
160
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
161 return factory;
1229
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
162 }
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
163
2337
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
164
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
165 public static void registerAsMBean(SessionFactory factory) {
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
166
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
167 StatisticsService statsMBean = new StatisticsService();
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
168 statsMBean.setSessionFactory(factory);
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
169 statsMBean.setStatisticsEnabled(true);
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
170
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
171 try {
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
172 MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
173 mbs.registerMBean(
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
174 statsMBean,
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
175 new ObjectName("Hibernate:application=Statistics"));
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
176
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
177 log.info("Enabled JMX support for hibernate.");
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
178 }
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
179 catch (MalformedObjectNameException mone) {
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
180 log.warn(mone, mone);
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
181 }
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
182 catch (InstanceAlreadyExistsException iaee) {
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
183 log.warn(iaee, iaee);
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
184 }
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
185 catch (MBeanRegistrationException mbre) {
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
186 log.warn(mbre, mbre);
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
187 }
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
188 catch (NotCompliantMBeanException ncmbe) {
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
189 log.warn(ncmbe, ncmbe);
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
190 }
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
191 }
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
192
52d712cd2384 Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1237
diff changeset
193
1229
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
194 public static Configuration createConfiguration() {
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
195 return createConfiguration(
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
196 DEFAULT_USER,
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
197 DEFAULT_PASSWORD,
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
198 DEFAULT_DIALECT,
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
199 DEFAULT_DRIVER,
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
200 DEFAULT_URL);
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
201 }
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
202
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
203 public static Configuration createConfiguration(
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
204 String user,
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
205 String password,
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
206 String dialect,
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
207 String driver,
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
208 String url
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
209 ) {
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
210 Configuration cfg = new Configuration();
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
211
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
212 // TODO: Use package reflection here.
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
213 cfg.addAnnotatedClass(Annotation.class);
763
8076f6a689d0 First part of flys/issue18
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 760
diff changeset
214 cfg.addAnnotatedClass(AnnotationType.class);
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
215 cfg.addAnnotatedClass(Attribute.class);
1230
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1229
diff changeset
216 cfg.addAnnotatedClass(Building.class);
2364
efe19e669092 Added and registered a model Catchment for 'catchment' relation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2363
diff changeset
217 cfg.addAnnotatedClass(Catchment.class);
1194
491892931761 Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1193
diff changeset
218 cfg.addAnnotatedClass(CrossSection.class);
1203
3c01bef43a98 Querprofile: Added a table to map the points to a given km.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1195
diff changeset
219 cfg.addAnnotatedClass(CrossSectionLine.class);
1194
491892931761 Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1193
diff changeset
220 cfg.addAnnotatedClass(CrossSectionPoint.class);
1230
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1229
diff changeset
221 cfg.addAnnotatedClass(CrossSectionTrack.class);
1236
324cb486db9f Added relation and hibernate classes for DGMs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1232
diff changeset
222 cfg.addAnnotatedClass(DGM.class);
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
223 cfg.addAnnotatedClass(DischargeTable.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
224 cfg.addAnnotatedClass(DischargeTableValue.class);
760
c8a2fbc612be Register the backend model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 464
diff changeset
225 cfg.addAnnotatedClass(Edge.class);
1230
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1229
diff changeset
226 cfg.addAnnotatedClass(Fixpoint.class);
1237
774dff3ee546 Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1236
diff changeset
227 cfg.addAnnotatedClass(Floodplain.class);
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
228 cfg.addAnnotatedClass(Gauge.class);
2363
a8f408fdf58c Added model for 'hws' relation and synced postgis with oracle spatial schema.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2362
diff changeset
229 cfg.addAnnotatedClass(Hws.class);
1210
31d8638760b1 New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1203
diff changeset
230 cfg.addAnnotatedClass(HYK.class);
31d8638760b1 New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1203
diff changeset
231 cfg.addAnnotatedClass(HYKEntry.class);
31d8638760b1 New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1203
diff changeset
232 cfg.addAnnotatedClass(HYKFormation.class);
31d8638760b1 New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1203
diff changeset
233 cfg.addAnnotatedClass(HYKFlowZoneType.class);
31d8638760b1 New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1203
diff changeset
234 cfg.addAnnotatedClass(HYKFlowZone.class);
1230
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1229
diff changeset
235 cfg.addAnnotatedClass(Line.class);
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
236 cfg.addAnnotatedClass(MainValueType.class);
189
bc3747a371cc First part of parsing main values.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 179
diff changeset
237 cfg.addAnnotatedClass(NamedMainValue.class);
bc3747a371cc First part of parsing main values.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 179
diff changeset
238 cfg.addAnnotatedClass(MainValue.class);
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
239 cfg.addAnnotatedClass(Position.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
240 cfg.addAnnotatedClass(Range.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
241 cfg.addAnnotatedClass(River.class);
1230
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1229
diff changeset
242 cfg.addAnnotatedClass(RiverAxis.class);
2360
9df06b88c079 Added model class for relation 'river_axes_km'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2346
diff changeset
243 cfg.addAnnotatedClass(RiverAxisKm.class);
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
244 cfg.addAnnotatedClass(TimeInterval.class);
2346
f834b411ca57 Added db table, model class and importer stuff for units.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2337
diff changeset
245 cfg.addAnnotatedClass(Unit.class);
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
246 cfg.addAnnotatedClass(WstColumn.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
247 cfg.addAnnotatedClass(WstColumnQRange.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
248 cfg.addAnnotatedClass(WstColumnValue.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
249 cfg.addAnnotatedClass(Wst.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
250 cfg.addAnnotatedClass(WstQRange.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
251
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
252 if (log.isDebugEnabled()) {
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
253 log.debug("user: " + user);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
254 log.debug("dialect: " + dialect);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
255 log.debug("driver: " + driver);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
256 log.debug("url: " + url);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
257 }
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
258
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
259 Properties props = new Properties();
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
260
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
261 // We rely on our own connection pool
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
262 props.setProperty(
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
263 "hibernate.connection.provider_class",
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
264 "org.hibernate.connection.DBCPConnectionProvider");
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
265
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
266 props.setProperty(Environment.DIALECT, dialect);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
267 props.setProperty(Environment.USER, user);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
268 props.setProperty(Environment.PASS, password);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
269 props.setProperty(Environment.DRIVER, driver);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
270 props.setProperty(Environment.URL, url);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
271
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
272 cfg.mergeProperties(props);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
273
1229
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
274 return cfg;
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
275 }
2361
e9b0fd1de89d Made flys-backend compatible with oracle spatial.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2360
diff changeset
276
e9b0fd1de89d Made flys-backend compatible with oracle spatial.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2360
diff changeset
277
2362
2649151c9500 Added some functions that return information about the db connection used by the current database session.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2361
diff changeset
278 public static String getProperty(SessionFactoryImpl factory, String key) {
2361
e9b0fd1de89d Made flys-backend compatible with oracle spatial.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2360
diff changeset
279 Properties props = factory.getProperties();
2362
2649151c9500 Added some functions that return information about the db connection used by the current database session.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2361
diff changeset
280 return props.getProperty(key);
2649151c9500 Added some functions that return information about the db connection used by the current database session.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2361
diff changeset
281 }
2361
e9b0fd1de89d Made flys-backend compatible with oracle spatial.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2360
diff changeset
282
2362
2649151c9500 Added some functions that return information about the db connection used by the current database session.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2361
diff changeset
283 public static String getUser(SessionFactoryImpl factory) {
2649151c9500 Added some functions that return information about the db connection used by the current database session.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2361
diff changeset
284 return getProperty(factory, Environment.USER);
2649151c9500 Added some functions that return information about the db connection used by the current database session.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2361
diff changeset
285 }
2649151c9500 Added some functions that return information about the db connection used by the current database session.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2361
diff changeset
286
2649151c9500 Added some functions that return information about the db connection used by the current database session.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2361
diff changeset
287
2649151c9500 Added some functions that return information about the db connection used by the current database session.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2361
diff changeset
288 public static String getPass(SessionFactoryImpl factory) {
2649151c9500 Added some functions that return information about the db connection used by the current database session.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2361
diff changeset
289 return getProperty(factory, Environment.PASS);
2649151c9500 Added some functions that return information about the db connection used by the current database session.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2361
diff changeset
290 }
2649151c9500 Added some functions that return information about the db connection used by the current database session.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2361
diff changeset
291
2649151c9500 Added some functions that return information about the db connection used by the current database session.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2361
diff changeset
292
2649151c9500 Added some functions that return information about the db connection used by the current database session.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2361
diff changeset
293 public static String getURL(SessionFactoryImpl factory) {
2649151c9500 Added some functions that return information about the db connection used by the current database session.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2361
diff changeset
294 return getProperty(factory, Environment.URL);
2649151c9500 Added some functions that return information about the db connection used by the current database session.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2361
diff changeset
295 }
2649151c9500 Added some functions that return information about the db connection used by the current database session.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2361
diff changeset
296
2649151c9500 Added some functions that return information about the db connection used by the current database session.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2361
diff changeset
297
2649151c9500 Added some functions that return information about the db connection used by the current database session.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2361
diff changeset
298 public static String getDriver(SessionFactoryImpl factory) {
2649151c9500 Added some functions that return information about the db connection used by the current database session.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2361
diff changeset
299 return getProperty(factory, Environment.DRIVER);
2361
e9b0fd1de89d Made flys-backend compatible with oracle spatial.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2360
diff changeset
300 }
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
301 }
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
302 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org