Mercurial > dive4elements > river
annotate flys-backend/src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java @ 2342:3efc3942b765
CrossSectionLine: Moved some logic from cross section demo app to this model.
flys-backend/trunk@2839 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 27 Sep 2011 13:37:34 +0000 |
parents | 52d712cd2384 |
children | f834b411ca57 |
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 |
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
|
17 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
|
18 |
176
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 import org.hibernate.cfg.Configuration; |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 import org.hibernate.cfg.Environment; |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 import de.intevation.flys.model.Annotation; |
763
8076f6a689d0
First part of flys/issue18
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
760
diff
changeset
|
23 import de.intevation.flys.model.AnnotationType; |
176
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 import de.intevation.flys.model.Attribute; |
1230
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1229
diff
changeset
|
25 import de.intevation.flys.model.Building; |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1193
diff
changeset
|
26 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
|
27 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
|
28 import de.intevation.flys.model.CrossSectionPoint; |
1230
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1229
diff
changeset
|
29 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
|
30 import de.intevation.flys.model.DGM; |
176
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 import de.intevation.flys.model.DischargeTable; |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 import de.intevation.flys.model.DischargeTableValue; |
760
c8a2fbc612be
Register the backend model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
464
diff
changeset
|
33 import de.intevation.flys.model.Edge; |
1230
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1229
diff
changeset
|
34 import de.intevation.flys.model.Fixpoint; |
1237
774dff3ee546
Added relation and hibernate classes for floodplains (german 'Talaue').
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1236
diff
changeset
|
35 import de.intevation.flys.model.Floodplain; |
176
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 import de.intevation.flys.model.Gauge; |
1210
31d8638760b1
New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
37 import de.intevation.flys.model.HYK; |
31d8638760b1
New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
38 import de.intevation.flys.model.HYKEntry; |
31d8638760b1
New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
39 import de.intevation.flys.model.HYKFormation; |
31d8638760b1
New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
40 import de.intevation.flys.model.HYKFlowZoneType; |
31d8638760b1
New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
41 import de.intevation.flys.model.HYKFlowZone; |
1230
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1229
diff
changeset
|
42 import de.intevation.flys.model.Line; |
176
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 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
|
44 import de.intevation.flys.model.NamedMainValue; |
bc3747a371cc
First part of parsing main values.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
179
diff
changeset
|
45 import de.intevation.flys.model.MainValue; |
176
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 import de.intevation.flys.model.Position; |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 import de.intevation.flys.model.Range; |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 import de.intevation.flys.model.River; |
1230
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1229
diff
changeset
|
49 import de.intevation.flys.model.RiverAxis; |
176
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 import de.intevation.flys.model.TimeInterval; |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 import de.intevation.flys.model.WstColumn; |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 import de.intevation.flys.model.WstColumnQRange; |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 import de.intevation.flys.model.WstColumnValue; |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 import de.intevation.flys.model.Wst; |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 import de.intevation.flys.model.WstQRange; |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 import org.apache.log4j.Logger; |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 public final class SessionFactoryProvider |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 { |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 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
|
62 |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 public static final String XPATH_USER = |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 "/artifact-database/backend-database/user/text()"; |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 public static final String XPATH_PASSWORD = |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 "/artifact-database/backend-database/password/text()"; |
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 public static final String XPATH_DIALECT = |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 "/artifact-database/backend-database/dialect/text()"; |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 public static final String XPATH_DRIVER = |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 "/artifact-database/backend-database/driver/text()"; |
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_URL = |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
76 "/artifact-database/backend-database/url/text()"; |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
77 |
179
aaac9c291067
Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
178
diff
changeset
|
78 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
|
79 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
|
80 |
aaac9c291067
Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
178
diff
changeset
|
81 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
|
82 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
|
83 |
aaac9c291067
Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
178
diff
changeset
|
84 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
|
85 System.getProperty( |
aaac9c291067
Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
178
diff
changeset
|
86 "flys.backend.dialect", |
1232
3383e042a655
Reverted the default db dialect back PostgreSQL.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1230
diff
changeset
|
87 "org.hibernate.dialect.PostgreSQLDialect"); |
176
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 DEFAULT_DRIVER = |
179
aaac9c291067
Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
178
diff
changeset
|
90 System.getProperty( |
aaac9c291067
Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
178
diff
changeset
|
91 "flys.backend.driver", |
aaac9c291067
Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
178
diff
changeset
|
92 "org.postgresql.Driver"); |
176
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
93 |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
94 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
|
95 System.getProperty( |
aaac9c291067
Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
178
diff
changeset
|
96 "flys.backend.url", |
aaac9c291067
Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
178
diff
changeset
|
97 "jdbc:postgresql://localhost:5432/flys"); |
176
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
98 |
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
|
99 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
|
100 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
|
101 |
176
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
102 private static SessionFactory sessionFactory; |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
103 |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
104 private SessionFactoryProvider() { |
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 |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
107 public static synchronized SessionFactory getSessionFactory() { |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
108 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
|
109 String user = |
82bc55666a97
Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
176
diff
changeset
|
110 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
|
111 String password = |
82bc55666a97
Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
176
diff
changeset
|
112 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
|
113 String dialect = |
82bc55666a97
Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
176
diff
changeset
|
114 Config.getStringXPath(XPATH_DIALECT, DEFAULT_DIALECT); |
464
d37ccb04ab5d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
189
diff
changeset
|
115 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
|
116 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
|
117 String url = |
82bc55666a97
Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
176
diff
changeset
|
118 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
|
119 |
82bc55666a97
Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
176
diff
changeset
|
120 sessionFactory = createSessionFactory( |
82bc55666a97
Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
176
diff
changeset
|
121 user, password, dialect, driver, url); |
176
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
122 } |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
123 return sessionFactory; |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
124 } |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
125 |
179
aaac9c291067
Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
178
diff
changeset
|
126 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
|
127 return createSessionFactory( |
aaac9c291067
Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
178
diff
changeset
|
128 DEFAULT_USER, |
aaac9c291067
Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
178
diff
changeset
|
129 DEFAULT_PASSWORD, |
aaac9c291067
Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
178
diff
changeset
|
130 DEFAULT_DIALECT, |
aaac9c291067
Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
178
diff
changeset
|
131 DEFAULT_DRIVER, |
aaac9c291067
Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
178
diff
changeset
|
132 DEFAULT_URL); |
aaac9c291067
Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
178
diff
changeset
|
133 } |
aaac9c291067
Default connection parameters are now overwritable with system properties.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
178
diff
changeset
|
134 |
178
82bc55666a97
Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
176
diff
changeset
|
135 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
|
136 String user, |
82bc55666a97
Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
176
diff
changeset
|
137 String password, |
82bc55666a97
Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
176
diff
changeset
|
138 String dialect, |
82bc55666a97
Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
176
diff
changeset
|
139 String driver, |
82bc55666a97
Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
176
diff
changeset
|
140 String url |
82bc55666a97
Expose the creation of the SessionFactory to the public to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
176
diff
changeset
|
141 ) { |
1229
8b12b338a3f6
Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
142 Configuration cfg = createConfiguration( |
8b12b338a3f6
Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
143 user, password, dialect, driver, url); |
8b12b338a3f6
Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
144 |
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
|
145 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
|
146 |
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
|
147 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
|
148 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
|
149 } |
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
|
150 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
|
151 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
|
152 } |
52d712cd2384
Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1237
diff
changeset
|
153 |
52d712cd2384
Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1237
diff
changeset
|
154 return factory; |
1229
8b12b338a3f6
Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
155 } |
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 |
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 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
|
159 |
52d712cd2384
Added code and a system property 'flys.backend.enablejmx=true' to enable JMX support for hibernate.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1237
diff
changeset
|
160 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
|
161 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
|
162 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
|
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 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
|
165 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
|
166 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
|
167 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
|
168 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
|
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 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
|
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 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
|
173 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
|
174 } |
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 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
|
176 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
|
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 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
|
179 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
|
180 } |
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 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
|
182 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
|
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 } |
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 |
1229
8b12b338a3f6
Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
187 public static Configuration createConfiguration() { |
8b12b338a3f6
Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
188 return createConfiguration( |
8b12b338a3f6
Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
189 DEFAULT_USER, |
8b12b338a3f6
Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
190 DEFAULT_PASSWORD, |
8b12b338a3f6
Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
191 DEFAULT_DIALECT, |
8b12b338a3f6
Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
192 DEFAULT_DRIVER, |
8b12b338a3f6
Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
193 DEFAULT_URL); |
8b12b338a3f6
Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
194 } |
8b12b338a3f6
Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
195 |
8b12b338a3f6
Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
196 public static Configuration createConfiguration( |
8b12b338a3f6
Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
197 String user, |
8b12b338a3f6
Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
198 String password, |
8b12b338a3f6
Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
199 String dialect, |
8b12b338a3f6
Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
200 String driver, |
8b12b338a3f6
Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
201 String url |
8b12b338a3f6
Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
202 ) { |
176
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
203 Configuration cfg = new Configuration(); |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
204 |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
205 // TODO: Use package reflection here. |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
206 cfg.addAnnotatedClass(Annotation.class); |
763
8076f6a689d0
First part of flys/issue18
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
760
diff
changeset
|
207 cfg.addAnnotatedClass(AnnotationType.class); |
176
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
208 cfg.addAnnotatedClass(Attribute.class); |
1230
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1229
diff
changeset
|
209 cfg.addAnnotatedClass(Building.class); |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1193
diff
changeset
|
210 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
|
211 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
|
212 cfg.addAnnotatedClass(CrossSectionPoint.class); |
1230
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1229
diff
changeset
|
213 cfg.addAnnotatedClass(CrossSectionTrack.class); |
1236
324cb486db9f
Added relation and hibernate classes for DGMs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1232
diff
changeset
|
214 cfg.addAnnotatedClass(DGM.class); |
176
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
215 cfg.addAnnotatedClass(DischargeTable.class); |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
216 cfg.addAnnotatedClass(DischargeTableValue.class); |
760
c8a2fbc612be
Register the backend model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
464
diff
changeset
|
217 cfg.addAnnotatedClass(Edge.class); |
1230
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1229
diff
changeset
|
218 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
|
219 cfg.addAnnotatedClass(Floodplain.class); |
176
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
220 cfg.addAnnotatedClass(Gauge.class); |
1210
31d8638760b1
New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
221 cfg.addAnnotatedClass(HYK.class); |
31d8638760b1
New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
222 cfg.addAnnotatedClass(HYKEntry.class); |
31d8638760b1
New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
223 cfg.addAnnotatedClass(HYKFormation.class); |
31d8638760b1
New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
224 cfg.addAnnotatedClass(HYKFlowZoneType.class); |
31d8638760b1
New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
225 cfg.addAnnotatedClass(HYKFlowZone.class); |
1230
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1229
diff
changeset
|
226 cfg.addAnnotatedClass(Line.class); |
176
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
227 cfg.addAnnotatedClass(MainValueType.class); |
189
bc3747a371cc
First part of parsing main values.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
179
diff
changeset
|
228 cfg.addAnnotatedClass(NamedMainValue.class); |
bc3747a371cc
First part of parsing main values.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
179
diff
changeset
|
229 cfg.addAnnotatedClass(MainValue.class); |
176
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
230 cfg.addAnnotatedClass(Position.class); |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
231 cfg.addAnnotatedClass(Range.class); |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
232 cfg.addAnnotatedClass(River.class); |
1230
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1229
diff
changeset
|
233 cfg.addAnnotatedClass(RiverAxis.class); |
176
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
234 cfg.addAnnotatedClass(TimeInterval.class); |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
235 cfg.addAnnotatedClass(WstColumn.class); |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
236 cfg.addAnnotatedClass(WstColumnQRange.class); |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
237 cfg.addAnnotatedClass(WstColumnValue.class); |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
238 cfg.addAnnotatedClass(Wst.class); |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
239 cfg.addAnnotatedClass(WstQRange.class); |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
240 |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
241 if (log.isDebugEnabled()) { |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
242 log.debug("user: " + user); |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
243 log.debug("dialect: " + dialect); |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
244 log.debug("driver: " + driver); |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
245 log.debug("url: " + url); |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
246 } |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
247 |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
248 Properties props = new Properties(); |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
249 |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
250 // We rely on our own connection pool |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
251 props.setProperty( |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
252 "hibernate.connection.provider_class", |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
253 "org.hibernate.connection.DBCPConnectionProvider"); |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
254 |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
255 props.setProperty(Environment.DIALECT, dialect); |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
256 props.setProperty(Environment.USER, user); |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
257 props.setProperty(Environment.PASS, password); |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
258 props.setProperty(Environment.DRIVER, driver); |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
259 props.setProperty(Environment.URL, url); |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
260 |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
261 cfg.mergeProperties(props); |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
262 |
1229
8b12b338a3f6
Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
263 return cfg; |
176
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
264 } |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
265 } |
3035d861a576
SessionFactoryProvider for access to the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
266 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |