annotate flys-backend/src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java @ 2809:f283212966e8

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

http://dive4elements.wald.intevation.org