Reputation: 7071
I have a struts project and my client give me full business logic classes.He need this ingrate with struts and hibernate.
Which is best, to put the business logic to my Dao layer , need to add an addtional service layer for business logic.
Some struts project i found that the action class directly access Dao.
Please suggest me which is better choice.help is highly appreciated.
Thanks,
Upvotes: 2
Views: 3304
Reputation: 5380
My suggestions is to keep Dao clean from your business logic but yes all the database related logic and customization should write at DAO layer like all hibernate logic, Casting of result into your Classes etc.. (As you are using Hibernate) should be written in DAO.
And whole iteration, setting/getting, result customization, preparation, request improvement to work as parameter for hibernate query should be written at service layer.
One another layer Controller
should work over service layer which will receive request and call respective service Method and provide generated response.
Upvotes: 2
Reputation: 8386
Let Hibernate be your DAO layer and write a service layer over that which contains your business rules. Those two together make up the model part of MVC. The Struts actions are the controller part of MVC.
Upvotes: 0
Reputation: 4829
I would highly suggest to write your business logic into service layer, so that your dao layer contains only database interaction and could be reusable at any point of time.
Also I would recommend you to add one presentation layer (all entities with plain values) that will be accessed by UI layer.
Upvotes: 2