Where should I create new entity - in presentation layer or not?

The controller is not the presentation layer. Its the C in MVC. The persistence layer should only be concerned with persistence, not Model object creation.

The code above is OK. Some would create the objects in the service, not in the controller, but the params are readily available in the controller so IMHO its acceptable.

Sorry my mistake calling the controller a presentation layer. I'm bit struggling with the layer stuff yet to figure out which is which. (English is not my first language) – Richards Jun 17 at 14:49.

Yes, the entity can be created at any layer. Some people prefer DTOs (separate objects with the same structure) which are then translated to the entities. Just avoid writing java code in the jsps.

Instantiate the objects in the controller, or leave that to some binding mechanism.

– hvgotcodes Jun 17 at 14:26 not in the jsp of course, but in the web layer (controllers) - yes. And actually - between the jsp and controllers - some binding mechanism. – Bozho Jun 17 at 14:27 I think he is referring to a set of objects in the Controller layer that mirror the domain layer.

You would than map the object returned from the domain layer to the controller objects. Seems redundant, but if the domain layer is actually behind a service than depending on the circumstances, may not be. – Casey Jun 17 at 14:28 @bozho, wouldn't it be more accurate to say in the controller or service layers, as opposed to any layer?

– hvgotcodes Jun 17 at 14:31 it can be any layer, even the UI layer if it is not JSP (if it is gwt or vaadin for example) – Bozho Jun 17 at 14:46.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions