JPA Support
It is possible to use JPA for the persistence of flow instance information. This support is implemented using querydsl.
Tested Databases:
-
MySQL 5.5
-
PostgreSQL 9.5
-
H2 1.3.170
Setup
Using Spring
Spring configuration classes are provided and just need to be imported.
Your application context only needs to provide JPQLTemplates
and
an EntityManager
with the brainslug.jpa.entity
package entities registered.
@Configuration
@Import({SpringBrainslugConfiguration.class, SpringDatabaseConfiguration.class})
public class BrainslugConfiguration {
@Bean
JPQLTemplates jpqlTemplates() {
return new HQLTemplates();
}
@Bean
FlowBuilder aFlow() {
...
}
}
Using existing EntityManager
First you need an instance of brainslug.jdbc.Database
:
new Database(entityManager, new HQLTemplates()); // adjust templates to your JPA provider
to create a the JPA TokenStore, JPA PropertyStore and JPA AsyncTriggerStore
JpaTokenStore jpaTokenStore = new JpaTokenStore(...)
JpaAsyncTriggerStore jpaAsyncTriggerStore = new JpaAsyncTriggerStore(...)
JpaPropertyStore jpaPropertyStore = new JpaPropertyStore(...)
These can than be provided to the BrainslugContextBuilder
:
new BrainslugContextBuilder()
.withTokenStore(jpaTokenStore)
.withAsyncTriggerStore(jpaAsyncTriggerStore)
.withPropertyStore(jpaPropertyStore)
.build()