DDD for the web application, should I put a rich domain object in the presentation layer?


I am trying to develop a web application by DDD. But in the best practice, I am not sure should I put rich domain objects into web session directly? For example: as the link suggest, it put the EntityManager to the domain object, I think it is not good if I want to put the domain object into the web session.

So, could you share some real experiences to apply DDD to a web application? especially how to deal with the rich domain objects with web session? and is there any good demo application (by Java) I can reference?

Thanks, Leon

Dear MikeSW, MaxS, thanks for your valuable answers.

So, in practice, if I use DDD, I still have to crate an shallow(anemic) object model, or DTO, to share data between presentation layer and service(business) layer.

Is my understanding correct?

If there is any good reference application or articles that talk about similar architecture, please kindly let me know. I have tried to find some, but hoped to see more.

Thanks, Leon

Domain objects (or any complex object) shouldn't be put in Session for both technical (resource waste) and semantical reasons. Session is not ment to be a Cache, but a holder of tmeporary user data. Store the object id maybe in the Session and then use the Repository to retrieve the actual object. The repository may cache things if required.