views:

226

answers:

1

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 ).

+2  A: 

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.

Stefan Steinegger