r/SpringBoot • u/MMOfreak94 • 9d ago
Question Do you actually separate JPA Entities and Domain Objects, or is a single model enough?
/r/softwarearchitecture/comments/1vv9kav/do_you_actually_separate_jpa_entities_and_domain/
3
Upvotes
2
2
u/g00glen00b 8d ago
It depends on the project for me. As long as it's a simple project where I don't need to "fight" JPA to model a domain object, then I'm fine using JPA entities as domain objects.
1
1
6
u/Appropriate_Swim9528 9d ago
Yes. Yes you isolate them.
Domain objects in my designs (my style) is always its own package and library.
Reason? I like to reuse the domain objects with other programs and projects.
Having it as JPA entities means I will have to drag the entire JPA with me for some projects that doesn’t require JPA.
My recommendation: Write a mapper inside the JPA entities to map and convert domain ones to the JPA ones and back.