I think I might possibly, perchance, accidentally, unwittingly have been missing something the last couple of years.
I have generally struggled to bring a rich domain model into play when building web applications. The main reason for this is that a web application is for all practical purposes stateless. The problem I have (had?) is that I do not want to bring the whole "rich" domain model to life just for one "web" call. I.e. I do not want to load the whole model (I'm not talking about lazy loading concepts here) attach listeners (on to the model) where neccesary and then detach the listeners and "remove" the model just for one call. Also to me a rich domain (OO) model implies state, else I'm actually just back to normal procedural programming but with the benefit of "grouping".
So, to date, I've used the standard web patterns and tools e.g. front controller, session facade (and in the java world the standard BOs and DAOs) with hibernate etc. However my domain model (or entities) were pretty dumb (and persisted with (n)Hibernate) and would probably have been the poster child for the anemic domain model. (PS. I still think the anemic domain model has its place)
Well, today I again paged through my Domain Driven Design book (Eric Evans) and skimmed through repositories (since I've been using it WAAAY before the book was even a gleam in Eric's eye) and something struck me. What if, instead of creating a new repository everytime (like it seems a lot of people do) I keep it around.
What if the repository was implemented with the aid of that other (bad child) pattern named Singleton. It would mean that my Repository would be in memory for the duration of the web application, and not just the one web call. All the CRUD operation can then take place through the Repository and since the Repistory is not destroyed everytime, it means I can even attach event handlers etc to my objects.
Admittadly it's not as easy as it sounds. One of the possible problems is that you'd end up with the whole database in memory and that is definately a BAD idea. Still, I think I'll persue this line of thought further and see where it leads me.
If you have any thoughts or experience in this regard, I'm eager to hear from you.