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