Data Access Module¶
Part I.
- Secondary Adapter to DB
- Mapper
- Explicit Repositories to DB
flowchart TB
subgraph adapter
end
subgraph entity
end
subgraph exception
end
subgraph mapper
end
subgraph repository
end
repository --> adapter
mapper --> adapter
entity --> adapter
exception --> adapter
Recommendations¶
Follow these steps¶
- Create an entity class.
- [Optional] Create an exception class.
- Create a mapper class:
- Method From Entity to Domain Model.
- Method From Domain Model to Entity.
- Create a Jpa Repository.
- Create an adapter for jpa repository (Secondary Adapter).
- [Optional] Implement Domain OutPort(Repository).
Dependencies¶
πΎ Migrations with liquibase¶
Recommendation: Use the following keywords to filename, for instance:
DDL: For schema or structural changes such as creating tables, modifying columns, adding indexes, or constraints.
DML: For data operations such as inserting, updating, or deleting records.
DATA: For large data imports, migrations, or initial data loads.
Patch: For small fixes or patches applied to correct data or structure issues. View: For database view creation or modifications.
Proc: For creating or altering stored procedures or functions in the database.
Example:
Project Structure¶
src
βββ java/
β βββ com.blanksystem.blank.service.data
β βββ adapter/
β β βββ *.java
β βββ entity/
β β βββ *.java
β βββ exception/
β β βββ *.java
β βββ mapper/
β β βββ *.java
β βββ repository/
β βββ *JPARepository.java
βββ resources/
βββ db/
βββ changelog/
βββ db.changelog-master.yaml
βββ ddl-v.0.0.1.yaml
2'DO¶
- Support other databases