Discussions

EJB design: struts, hibernate decoupling

  1. struts, hibernate decoupling (6 messages)

    Can anyone suggest me the best approach to decouple the hibernate layer from my struts web tier. I was thinking of a session bean masking the hibernate layer or a java class which has methods exposed for the users to call and will talk to the hibernate on behalf. Thanks Kalpana

    Threaded Messages (6)

  2. struts, hibernate decoupling[ Go to top ]

    The best approach would be to have a business delegate pattern, which will invoke the hibernate calls. You can make use the helper pattern, where you do the exact implementations of the business logics in the helper classes. The methods of the helper class will be invoked from the business delegate. This way you can decouple the struts and hibernate.
  3. Re: struts, hibernate decoupling[ Go to top ]

    Put Spring in between. Spring controllers can controls Hibernate and Struts, passing requests and replies back and forth between the two with neither being aware of the existence of the other (or indeed of Spring being there at all).
  4. Re: struts, hibernate decoupling[ Go to top ]

    Create services, services will use dao for crud operations. And use this services in your actions. and you will not have even a single line of code in your action You can use spring to make things even more easier, specially for hibernate. jYog
  5. Re: struts, hibernate decoupling[ Go to top ]

    This is a similar kind of question, I had in mind sometime back, then I found a good resource as follows: http://question2answer.googlepages.com/data-access-object-DAO.html This helped me in getting an idea about how to decouple model layer from persistence layer. Hope this helps. Thanks.
  6. DTO vs entities[ Go to top ]

    An important question you need to see is related to the kind of object you will show in the Struts layer. In a simple application, and for some simple processes, you might prefer transferring the domain model pojos (Hibernate entities) directly in the Struts layer. Therefore you will use the "open session in view" pattern already implemented by both Hibernate and Spring. For some other cases, when the web layer is modifying the transfered object, you might need to use DTOs to separate the view, business and model layers. But this is not an obvious choice. Using DTOs is sometime a waste of time and code, but it can prevent the application of falling in some Hibernate "not wanted and uncontrolled" features like transaction, save & update handling to name few. regards,
  7. Re: struts, hibernate decoupling[ Go to top ]

    Thank you all, for your replies.