Sunday, May 1, 2011

hibernate DAO design

do i have to open and close session and transcation in each function (make object ,delete object ,findbyID)

can u give me a DAO implenetation for findall (lazy initialization ).

From stackoverflow
  • You should have a transaction for each complete business operation. I For instance: The operation includes selecting some values, updating it and inserting others. If each of the elementary operations create their own transaction, you will fail writing a multi-user application.

    You should create the session at the beginning of the business operation, create a transaction, then perform all the operations (you "functions") within that transaction, and commit or rollback them all together.

    Transactions are defined in the business layer.

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.