3. JPA Property Configuration

These are the two DB specific properties files that are loaded by their respective Spring profiles in dao-datasource-context.xml.

sql/hsql.properties
                
jdbc.driver.class=org.hsqldb.jdbcDriver
jdbc.url=jdbc:hsqldb:mem:contact
jdbc.username=sa
jdbc.password=

jdbc.initial.size=1
jdbc.min.idle=1
jdbc.max.idle=2
jdbc.max.active=4
jdbc.time.between.eviction=30000
jdbc.min.evictable.idle=60000
jdbc.validation.query.timeout=30000
jdbc.validation.query=select 1 from INFORMATION_SCHEMA.SYSTEM_USERS
            
jpa.persistence.unit.name=hsql
jpa.show.sql=false

jpa.cache.use_second_level_cache=false
                
            

It is expected that the database is already initialzed before running the application. In the contact-app project there is a scripts directory that contains init-postgres.sh and reinit-postgres.sh. The first script will just create the DB, user, and schema. The second will drop the DB and user first, before creating everything.

[Note]Note

DB Connection Pool min/max/idle/timeouts should be tuned for each application based on load testing.

sql/postgresql.properties
                
jdbc.driver.class=org.postgresql.Driver
jdbc.url=jdbc:postgresql://localhost:5432/contact
jdbc.username=contact
jdbc.password=contact

jdbc.initial.size=5
jdbc.min.idle=5
jdbc.max.idle=10
jdbc.max.active=20
jdbc.time.between.eviction=30000
jdbc.min.evictable.idle=60000
jdbc.validation.query.timeout=30000
jdbc.validation.query=select version()

jpa.persistence.unit.name=postgresql
jpa.show.sql=false  1

jpa.cache.use_second_level_cache=true
                
            
1 This can be set to true by passing it in as a Java system property or by setting it in a contact-app.properties file.