annotate flys-backend/src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java @ 2810:04eeb45df27b

Implemented model classes and importer classes for bed height epochs. flys-backend/trunk@4222 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 12 Apr 2012 12:50:49 +0000
parents f283212966e8
children 8979f2294af9
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;
2810
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2809
diff changeset
27 import de.intevation.flys.model.BedHeightEpoch;
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2809
diff changeset
28 import de.intevation.flys.model.BedHeightEpochValue;
2809
f283212966e8 Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2802
diff changeset
29 import de.intevation.flys.model.BedHeightSingle;
f283212966e8 Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2802
diff changeset
30 import de.intevation.flys.model.BedHeightSingleValue;
f283212966e8 Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2802
diff changeset
31 import de.intevation.flys.model.BedHeightType;
1230
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1229
diff changeset
32 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
33 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
34 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
35 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
36 import de.intevation.flys.model.CrossSectionPoint;
1230
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1229
diff changeset
37 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
38 import de.intevation.flys.model.DGM;
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39 import de.intevation.flys.model.DischargeTable;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 import de.intevation.flys.model.DischargeTableValue;
760
c8a2fbc612be Register the backend model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 464
diff changeset
41 import de.intevation.flys.model.Edge;
2809
f283212966e8 Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2802
diff changeset
42 import de.intevation.flys.model.ElevationModel;
1230
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1229
diff changeset
43 import de.intevation.flys.model.Fixpoint;
2799
501f00e355eb Added model class for 'floodmaps'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2364
diff changeset
44 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
45 import de.intevation.flys.model.Floodplain;
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 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
47 import de.intevation.flys.model.Hws;
1210
31d8638760b1 New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1203
diff changeset
48 import de.intevation.flys.model.HYK;
31d8638760b1 New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1203
diff changeset
49 import de.intevation.flys.model.HYKEntry;
31d8638760b1 New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1203
diff changeset
50 import de.intevation.flys.model.HYKFormation;
31d8638760b1 New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1203
diff changeset
51 import de.intevation.flys.model.HYKFlowZoneType;
31d8638760b1 New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1203
diff changeset
52 import de.intevation.flys.model.HYKFlowZone;
1230
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1229
diff changeset
53 import de.intevation.flys.model.Line;
2809
f283212966e8 Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2802
diff changeset
54 import de.intevation.flys.model.LocationSystem;
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55 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
56 import de.intevation.flys.model.NamedMainValue;
bc3747a371cc First part of parsing main values.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 179
diff changeset
57 import de.intevation.flys.model.MainValue;
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58 import de.intevation.flys.model.Position;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59 import de.intevation.flys.model.Range;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60 import de.intevation.flys.model.River;
1230
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1229
diff changeset
61 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
62 import de.intevation.flys.model.RiverAxisKm;
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63 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
64 import de.intevation.flys.model.Unit;
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65 import de.intevation.flys.model.WstColumn;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66 import de.intevation.flys.model.WstColumnQRange;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
67 import de.intevation.flys.model.WstColumnValue;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
68 import de.intevation.flys.model.Wst;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
69 import de.intevation.flys.model.WstQRange;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
70
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
71 import org.apache.log4j.Logger;
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 final class SessionFactoryProvider
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 static Logger log = Logger.getLogger(SessionFactoryProvider.class);
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 public static final String XPATH_USER =
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
78 "/artifact-database/backend-database/user/text()";
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
79
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
80 public static final String XPATH_PASSWORD =
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
81 "/artifact-database/backend-database/password/text()";
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
82
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
83 public static final String XPATH_DIALECT =
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
84 "/artifact-database/backend-database/dialect/text()";
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
85
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
86 public static final String XPATH_DRIVER =
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
87 "/artifact-database/backend-database/driver/text()";
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
88
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
89 public static final String XPATH_URL =
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
90 "/artifact-database/backend-database/url/text()";
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
91
179
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
92 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
93 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
94
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
95 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
96 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
97
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
98 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
99 System.getProperty(
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
100 "flys.backend.dialect",
1232
3383e042a655 Reverted the default db dialect back PostgreSQL.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1230
diff changeset
101 "org.hibernate.dialect.PostgreSQLDialect");
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
102
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
103 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
104 System.getProperty(
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
105 "flys.backend.driver",
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
106 "org.postgresql.Driver");
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
107
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
108 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
109 System.getProperty(
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
110 "flys.backend.url",
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
111 "jdbc:postgresql://localhost:5432/flys");
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
112
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
113 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
114 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
115
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
116 private static SessionFactory sessionFactory;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
117
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
118 private SessionFactoryProvider() {
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
119 }
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
120
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
121 public static synchronized SessionFactory getSessionFactory() {
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
122 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
123 String user =
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
124 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
125 String password =
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
126 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
127 String dialect =
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
128 Config.getStringXPath(XPATH_DIALECT, DEFAULT_DIALECT);
464
d37ccb04ab5d Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 189
diff changeset
129 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
130 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
131 String url =
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
132 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
133
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
134 sessionFactory = createSessionFactory(
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
135 user, password, dialect, driver, url);
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
136 }
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
137 return sessionFactory;
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
138 }
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
139
179
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
140 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
141 return createSessionFactory(
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
142 DEFAULT_USER,
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
143 DEFAULT_PASSWORD,
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
144 DEFAULT_DIALECT,
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
145 DEFAULT_DRIVER,
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
146 DEFAULT_URL);
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
147 }
aaac9c291067 Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 178
diff changeset
148
178
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
149 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
150 String user,
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
151 String password,
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
152 String dialect,
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
153 String driver,
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
154 String url
82bc55666a97 Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 176
diff changeset
155 ) {
1229
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
156 Configuration cfg = createConfiguration(
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
157 user, password, dialect, driver, url);
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
158
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
159 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
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 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
162 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
163 }
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 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
165 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
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
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 return factory;
1229
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
169 }
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
170
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
171
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 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
173
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 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
175 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
176 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
177
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 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
179 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
180 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
181 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
182 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
183
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 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
185 }
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 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
187 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
188 }
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 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
190 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
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 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
193 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
194 }
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
195 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
196 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
197 }
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
198 }
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
199
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
200
1229
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
201 public static Configuration createConfiguration() {
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
202 return createConfiguration(
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
203 DEFAULT_USER,
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
204 DEFAULT_PASSWORD,
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
205 DEFAULT_DIALECT,
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
206 DEFAULT_DRIVER,
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
207 DEFAULT_URL);
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
208 }
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
209
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
210 public static Configuration createConfiguration(
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
211 String user,
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
212 String password,
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
213 String dialect,
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
214 String driver,
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
215 String url
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
216 ) {
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
217 Configuration cfg = new Configuration();
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
218
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
219 // TODO: Use package reflection here.
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
220 cfg.addAnnotatedClass(Annotation.class);
763
8076f6a689d0 First part of flys/issue18
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 760
diff changeset
221 cfg.addAnnotatedClass(AnnotationType.class);
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
222 cfg.addAnnotatedClass(Attribute.class);
2810
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2809
diff changeset
223 cfg.addAnnotatedClass(BedHeightEpoch.class);
04eeb45df27b Implemented model classes and importer classes for bed height epochs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2809
diff changeset
224 cfg.addAnnotatedClass(BedHeightEpochValue.class);
2809
f283212966e8 Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2802
diff changeset
225 cfg.addAnnotatedClass(BedHeightSingle.class);
f283212966e8 Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2802
diff changeset
226 cfg.addAnnotatedClass(BedHeightSingleValue.class);
f283212966e8 Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2802
diff changeset
227 cfg.addAnnotatedClass(BedHeightType.class);
1230
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1229
diff changeset
228 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
229 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
230 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
231 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
232 cfg.addAnnotatedClass(CrossSectionPoint.class);
1230
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1229
diff changeset
233 cfg.addAnnotatedClass(CrossSectionTrack.class);
1236
324cb486db9f Added relation and hibernate classes for DGMs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1232
diff changeset
234 cfg.addAnnotatedClass(DGM.class);
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
235 cfg.addAnnotatedClass(DischargeTable.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
236 cfg.addAnnotatedClass(DischargeTableValue.class);
760
c8a2fbc612be Register the backend model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 464
diff changeset
237 cfg.addAnnotatedClass(Edge.class);
2809
f283212966e8 Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2802
diff changeset
238 cfg.addAnnotatedClass(ElevationModel.class);
1230
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1229
diff changeset
239 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
240 cfg.addAnnotatedClass(Floodplain.class);
2802
3fdac7b43dac Registered missing Floodmaps and set its Geometry type to Geometry.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2799
diff changeset
241 cfg.addAnnotatedClass(Floodmaps.class);
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
242 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
243 cfg.addAnnotatedClass(Hws.class);
1210
31d8638760b1 New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1203
diff changeset
244 cfg.addAnnotatedClass(HYK.class);
31d8638760b1 New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1203
diff changeset
245 cfg.addAnnotatedClass(HYKEntry.class);
31d8638760b1 New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1203
diff changeset
246 cfg.addAnnotatedClass(HYKFormation.class);
31d8638760b1 New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1203
diff changeset
247 cfg.addAnnotatedClass(HYKFlowZoneType.class);
31d8638760b1 New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1203
diff changeset
248 cfg.addAnnotatedClass(HYKFlowZone.class);
1230
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1229
diff changeset
249 cfg.addAnnotatedClass(Line.class);
2809
f283212966e8 Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2802
diff changeset
250 cfg.addAnnotatedClass(LocationSystem.class);
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
251 cfg.addAnnotatedClass(MainValueType.class);
189
bc3747a371cc First part of parsing main values.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 179
diff changeset
252 cfg.addAnnotatedClass(NamedMainValue.class);
bc3747a371cc First part of parsing main values.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 179
diff changeset
253 cfg.addAnnotatedClass(MainValue.class);
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
254 cfg.addAnnotatedClass(Position.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
255 cfg.addAnnotatedClass(Range.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
256 cfg.addAnnotatedClass(River.class);
1230
e2deda3b77a7 Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1229
diff changeset
257 cfg.addAnnotatedClass(RiverAxis.class);
2360
9df06b88c079 Added model class for relation 'river_axes_km'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2346
diff changeset
258 cfg.addAnnotatedClass(RiverAxisKm.class);
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
259 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
260 cfg.addAnnotatedClass(Unit.class);
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
261 cfg.addAnnotatedClass(WstColumn.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
262 cfg.addAnnotatedClass(WstColumnQRange.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
263 cfg.addAnnotatedClass(WstColumnValue.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
264 cfg.addAnnotatedClass(Wst.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
265 cfg.addAnnotatedClass(WstQRange.class);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
266
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
267 if (log.isDebugEnabled()) {
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
268 log.debug("user: " + user);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
269 log.debug("dialect: " + dialect);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
270 log.debug("driver: " + driver);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
271 log.debug("url: " + url);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
272 }
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
273
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
274 Properties props = new Properties();
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
275
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
276 // We rely on our own connection pool
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
277 props.setProperty(
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
278 "hibernate.connection.provider_class",
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
279 "org.hibernate.connection.DBCPConnectionProvider");
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
280
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
281 props.setProperty(Environment.DIALECT, dialect);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
282 props.setProperty(Environment.USER, user);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
283 props.setProperty(Environment.PASS, password);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
284 props.setProperty(Environment.DRIVER, driver);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
285 props.setProperty(Environment.URL, url);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
286
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
287 cfg.mergeProperties(props);
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
288
1229
8b12b338a3f6 Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1210
diff changeset
289 return cfg;
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
290 }
2361
e9b0fd1de89d Made flys-backend compatible with oracle spatial.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2360
diff changeset
291
e9b0fd1de89d Made flys-backend compatible with oracle spatial.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2360
diff changeset
292
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
293 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
294 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
295 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
296 }
2361
e9b0fd1de89d Made flys-backend compatible with oracle spatial.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2360
diff changeset
297
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
298 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
299 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
300 }
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
301
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
302
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
303 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
304 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
305 }
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
306
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
307
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
308 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
309 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
310 }
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
311
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
312
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
313 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
314 return getProperty(factory, Environment.DRIVER);
2361
e9b0fd1de89d Made flys-backend compatible with oracle spatial.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2360
diff changeset
315 }
176
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
316 }
3035d861a576 SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
317 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org