As I'm just learning all the fruits of Java and everything I wanted to find out one thing which was flying around in my mind for some time. The code bellow is quick example of two methods in two different classes. First one is obviously a controller for some page and the other one is part of service.
@RequestMapping("/something)
public void doSomething() {
...
SomeEntity example = new SomeEntity();
example.setAccount(account);
example.setSmthElse(else);
example.setDate(new Date());
example.setSomething(something);
someService.saveSomeEntity(example);
}
...
public void saveSomeEntity(SomeEntity object) {
someEntityDAO.save(object);
}
So my question here is should the creation of the new entity SomeEntity
and setting of it's properties be done in the presentation layer part as above or should it be done somehow in the saveSomeEntity
method by passing all the params to it?