There are multiple ways in OpenHub how to store custom business data.
See following variants:
Table of Contents | ||
---|---|---|
|
a) Adding tables to the OpenHub schema
...
- Add custom JPA entities
- Extend OpenHub database scheme with new objects (tables, sequences ...) . Directly in project database, flyway in OpenHub can be used as well. (https://flywaydb.org/)
Configure EntityManager, to scan custom packages, with OpenHub configuration property ohf.jpa.additional-packages
Example:Code Block ohf.jpa.additional-packages=org.openhubframework.openhub.ri.persistence
- Entity manager bean can be used for building custom dao, or configure repositories using spring-data-jpa.
...
- straightforward setup, except that OpenHubDatasource is Primary bean, so project has to work with Qualified dataSource.
- For example JdbcTemplate can be used that way, other frameworks build on top if, or entirelly wrapped service (not exposing beans to spring context).
c) Add second datasource, with global transaction (one transactionManager)
- SpringBoot autoconfiguration can be levered, either setup with JTA (Atomikos, Bitronix) or provided by application server.
- Project specific dataSource, entityManagerFactory (and entityManager) can be configured, to have two separate JPA contexts.
- Different databases can be configured for each JPA context as well.
...