-
Notifications
You must be signed in to change notification settings - Fork 41.1k
DataSource Initialization
-
when the
DataSource
is post-processed-
if DDL (schema) scripts are available:
-
they are applied to the
DataSource
-
if DML (data) scripts are available they are applied to the
DataSource
-
-
-
when the
LocalContainerEntityManagerFactoryBean
is post-processed-
if Hibernate initialised the schema publish
DataSourceSchemaCreatedEvent
-
-
when the
DataSourceSchemaCreatedEvent
is received-
if the schema hasn’t been initialised and DML (data) scripts are available they are applied to the
DataSource
-
The presence or absence of DDL (schema) scripts changes when DML (data) scripts are run. When DDL scripts are present, DML scripts are run immediately after the DDL scripts. When there are no DDL scripts, DML scripts are run once Hibernate has created the schema. If Hibernate isn’t being used DML scripts are never run, irrespective of any other component that may have created the schema. If you want to use a DDL script to manage parts of the schema that Hibernate won’t touch, your DML scripts cannot interact with parts of the schema that Hibernate creates as they’ll be run too soon.
The auto-configurations for Flyway and Liquibase create various …DependsOnPostProcessor
beans to ensure that JdbcOperations
, NamedParameterJdbcOperations
, and EntityManagerFactory
beans cannot be used until the database has been migrated. There are no …DependsOnPostProcessor
beans created for jOOQ. This means that the database may not have been initialized when accessed with jOOQ during application context refresh.
The Hibernate auto-configuration does not create any …DependsOnPostProcessor
beans. If there are no DDL scripts – so Hibernate will create the schema and cause DML scripts to be applied – the database may not have been initialised when accessed during application context refresh using anything other than Hibernate.