this is very controversy where i work, because there are 2 major opinions on this topic.
I'd like to hear others opinions about where should the business logic be placed. First, i'm gonna expose my opinion and Second, i'm going to expose some other guy opinion, so the ranchers can tell wich one they think is better.
Opinion 1 - If a business login belons/affects only one CMP (consequently only the rows of the CMP mapped table), insert this business login inside this CMP (an example would be "fillStock(30)"). But if the business login affects 2 or more CMPs, place this business logic inside a Session Bean between the Façade and CMPs(an example would be transferMoneyFromThisAccountToThatAccount(1, R$30, 2)"). Naturally, for accessing this 2 kind of methods there will be a Session Façade.
Opinion 2 - Always place the business logic inside a CMP, when this logic affects other CMPs, choose the one responsible for the login and place the business methods there. The same way, this logic will be accessed through a Façade.
Well, I'd be very gratefull if people discuss this 2 points of view and tell me (with arguments or an example) why anyone of them is better.
Thanks and Regards,
My suggestion would be, Don't keep any business logic in CMP. Entity beans represent tables, just keep the persistance logic, so that there will be a clear separation of business and persistance logic. Everybody knows that Entity bean is a mistake of EJB. If you feel that the performance is less after you impelement you can easily change the persistance logic later without affecting the business logic.
Hope this helps,
Yes. I would definitely agree with Senthil here.
I am also of the view that business logic be always kept away from the persistance mechanism, be it CMPs or whatever.
If ur using CMPs for persistance today, u might want to use something else tomorrow, for a host of different reasons.
If ur business logic is tightly coupled with the CMPs, u will find it increasingly difficult to move away from CMP.
A session facade would be much more useful and cleaner in this case.
Here's the point.
I used CMPs for the example, but the question is about any persisten mechanism (Hibernate, JDO, etc...).
Also, i'm taling about what is between the Façade and persistent mechanism (Façade -> .... -> CMPs).
We sure get a lot of benefits of placing the business logic inside POJOs or Session betweens to work between those 2, but the fact is that it might be considered not a pure OO design.