-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpostgres_hibernate.cfg.xml
More file actions
77 lines (64 loc) · 3.69 KB
/
Copy pathpostgres_hibernate.cfg.xml
File metadata and controls
77 lines (64 loc) · 3.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration SYSTEM
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<!--
Production Hibernate config for PostgreSQL.
TheTransitClock will pick up this file via the
-Dtransitclock.hibernate.configFile=... system property
(or the <hibernate><configFile> entry in transitclockConfig.xml).
Connection URL/user/password are intentionally NOT set here. The runbook
in docs/setup.md drives them from JVM system properties so that
-Dtransitclock.db.dbName=web (used by CreateAPIKey, the API tier in
CATALINA_OPTS, etc.) can redirect lookups between the per-agency and
`web` databases without editing this file.
HibernateUtils.createSessionFactory honours hibernate.connection.url
if it's set here, and only falls back to building the URL from
-Dtransitclock.db.dbHost / dbName / dbType when it isn't. Setting the
URL inline therefore silently nullifies the dbName overrides the rest
of the runbook depends on. Don't put it back unless you've also
removed every -Dtransitclock.db.dbName=... flag from your deployment.
HibernateUtils also appends reWriteBatchedInserts=true to the
constructed Postgres URL so the JDBC driver rewrites Hibernate batches
as multi-row INSERTs. If you override the URL inline you must add
?reWriteBatchedInserts=true yourself, or batch saves degrade to one
INSERT per row over the wire.
JVM properties used in place of inline settings:
-Dtransitclock.db.dbType=postgresql
-Dtransitclock.db.dbHost=localhost
-Dtransitclock.db.dbName=02 (or =web for API/CreateAPIKey)
-Dtransitclock.db.dbUserName=transitclock
-Dtransitclock.db.dbPassword=changeme
-->
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<!-- Quiet logging in production. -->
<property name="show_sql">false</property>
<property name="format_sql">false</property>
<property name="use_sql_comments">false</property>
<!-- C3P0 pool. Required for production: Hibernate's built-in pool is
explicitly not safe for production use. Setting any c3p0.* property
switches the pool over. -->
<property name="hibernate.c3p0.min_size">2</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">50</property>
<!-- Batched writes — DataDbLogger and DbWriter both push through
this. Should evenly divide transitclock.db.batchSize so each
DbWriter flush ships a whole number of JDBC batches. -->
<property name="hibernate.jdbc.batch_size">100</property>
<property name="default_batch_fetch_size">100</property>
<property name="hibernate.order_inserts">true</property>
<property name="hibernate.order_updates">true</property>
<property name="hibernate.connection.autocommit">true</property>
<!-- Schema is created up-front by SchemaGenerator + psql; we only want
additive changes from Hibernate, never destructive ones. If you
prefer to manage all DDL out-of-band (recommended for tightly
managed prod databases), switch this to "validate" so Hibernate
only checks the live schema against the entity mappings and
refuses to mutate it. -->
<property name="hibernate.hbm2ddl.auto">update</property>
<mapping resource="named_queries.hbm.xml" />
</session-factory>
</hibernate-configuration>