I am currently developing a spring boot web application in which no entity is persistent, and hence will not be saved on a database.
Although, I need to be able to query some business metrics from it. Suppose the following scenario:
EntityAbelongs to a third party API.
- An user on my web app requests to see some details of
- My app then requests
EntityAfrom the third party API, does some processing (could be combining that data with some other available on the web), and returns the desired info to the requesting user.
I am not required to persist
EntityA because it is already being persisted inside the third party API. All the processing done is transient. But, I want to be able to check how many times
EntityA was requested by an user on my web application, and what data it contained on each request. This metric is useful for audit purposes, for example, since the third party accepts input and output of data. I want to be able to check who input a certain piece of data, and how many times it was done.
If I were to persist
EntityA, I would not need all fields that the domain model contain. Also, I would have to add some metadata fields to it (date of request, requesting user, etc.).
What is the correct approach to it?
- Persist the domain model of
EntityAin my web app, adding the metadata fields on, for example, a superclass?
- Create a new entity that express the desired metric, for example
RequestedEntity, and map the desired fields of
EntityAto RequestedEntity before persisting?
Go to Source
Author: Gabriel Robaina