If one wants to comply with the clean architecture principle 100%, they must not annotate the entities in the entities layer with database-specific annotations (like Hibernate, Neo4j, etc.). So, two options remain:
- Creating a corresponding entity in the outer layer for each entity of the entities layer and putting annotations on them: This option may introduce many new classes and boilerplate code and also for each new database type we may need to create all of them once again. Thus, this option may do more harm than good.
- Using XML-based mappings instead of the annotation-based ones. Although, this may work for e.g., hibernate, it seems to me that XML-based mappings are not widely supported. For example, I could not find a good way of declaring mapping in XML for Neo4j OGM or Spring Data.
So, according to what I mentioned above, can it be concluded that most developers just ignore the principles of the clean architecture in this case and use annotations on their entities? (If they used the second option shouldn't have we seen a strong support for XML-based mappings? Even, according to what I have seen, there may be some objections to using XML-based mappings).
So, can I just annotate the entities without worry? If not, what is the best solution?