I am trying to configure multiple datasources for a spring boot 2 app, reading from a read only SQLite db file and writing results to a different SQLite db.
I can't find the correct property keys to set on the multiple datasources. I would like the code to generate the db for read/write data source, but I can't find the correct property key to use to tell hibernate to do this for me:
lsst.ajsdata.hibernate.hbm2ddl.auto=create
Does not work.
Can anybody help on how I should configure these datasources please.
application.properties ...
# DB PROPERTIES #
lsst.kracken.jdbcUrl = jdbc:sqlite:file:./data/kraken_2026.db?mode=ro
lsst.kracken.hibernate.dialect=org.hibernate.dialect.SQLiteDialect
lsst.kracken.driver-class-name = org.sqlite.JDBC
lsst.kracken.maximum-pool-size=10
lsst.kracken.hibernate.ddl-auto=none
lsst.kracken.show-sql=false
lsst.kracken.hibernate.format_sql=false
lsst.kracken.generate-ddl=true
lsst.ajsdata.jdbcUrl = jdbc:sqlite:file:./data/ajs_kraken_2026.db?mode=rw
lsst.ajsdata.driver-class-name = org.sqlite.JDBC
lsst.ajsdata.maximum-pool-size=30
lsst.ajsdata.default-auto-commit=true
lsst.ajsdata.hibernate.open-in-view=false
lsst.ajsdata.hibernate.hbm2ddl.auto=create
lsst.ajsdata.hibernate.ddl-auto=create
lsst.ajsdata.hibernate.generate-ddl=true
lsst.ajsdata.hibernate.use-new-id-generator-mappings=true
lsst.ajsdata.hibernate.jpa.show-sql=true
lsst.ajsdata.hibernate.dialect=org.hibernate.dialect.SQLiteDialect
lsst.ajsdata.hibernate.format_sql=true
#spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.SQLiteDialect
#spring.jpa.generate-ddl=false
##spring.jpa.hibernate.ddl-auto=none
#spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.globally_quoted_identifiers=true
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyComponentPathImpl
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
With the persistence context classes looking like this:
public class KrackenPersistenceContext {
@Bean
@Primary
@ConfigurationProperties(prefix="lsst.kracken")
public DataSource primaryDataSource() {
return DataSourceBuilder.create().build();
}
}
And:
public class AjsDataPersistenceContext {
@Bean
@ConfigurationProperties(prefix = "lsst.ajsdata")
@Qualifier("ajsDatasorce")
public DataSource ajsDatasorce() {
DataSource ajsDatasource = DataSourceBuilder.create().build();
return ajsDatasource;
}
}