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