I've been doing some reading lately and one thing that I've come across was this article about the Anaemic Domain Model from Martin Fowler. I know, it's old, but somehow very actual in Java world. So I'm trying to move towards a more domain-driven design. One option would be to go with the Active Record model. However, I don't really like the current implementation it has in Scala. It completely couples the domain objects with the persistence type (not so bad in most cases but I have a project where I need to store something both in a RDB and in Mongo). Then I ran across this article about Spring, Hibernate and Scala and though here too the domain object is coupled with the JPA trait, I noticed how he uses Spring to inject a Notification Service. Can't the same mechanism be used to inject a transparent DAO interface? Have you seen this used anywhere? Any thoughts on the idea?
Asked
Active
Viewed 384 times
0
-
what exactly is the problem you are trying to solve? You need to inject a repository/DAO into a domain object as it is fetched from the the DB? – tolitius Oct 12 '11 at 15:31
-
@tolitius Yes, that's the basic idea. But I'm not trying to solve anything. This is supposed to be a purely academical discussion if that would be a good idea, if you've seen it used and if yes where and with what degree of success. – Cristian Vrabie Oct 12 '11 at 19:14
1 Answers
0
You should have a look at Spring-Data, this project provides some kind of abstraction over different data storages.

Ralph
- 118,862
- 56
- 287
- 383
-
Isn't Spring Data, by its design supporting the anaemic domain model? – Cristian Vrabie Oct 12 '11 at 13:31