bug #7046
closedreplace open session per view pattern by DTO strategy
40%
Description
In #6687 the open session per view pattern has been implemented for the cdm-vaadin mvp framework.
It turned out that this approach is causing problems since a session opened in one view needs to be reused in multiple request threads. In order to accomplish this it is always required to have a transaction open for the whole lifetime of the view which causes an open database connection for the same time. The database connection pool is limited to a maximum amount of open connections and can thus run out of available connections when too many views are opened at the same time. This situation is becoming worse if vaadin views are not destroyed fast enough so that the resource are being freed quickly (#7047).
As explained in VaadinNotes the best way to avoid LazyInitializytionExceptions is to use DTOs or entity bean initialization strategies. This will not only allow to free database connections as quickly as possible but also avoids managing long transactions logs at in the database itself.
TODO:
- remove all open session per view pattern code
- use bean init-strategies to avoid LazyInitializytionExceptions
- in order to save edited entities, open a new clean session, merge the modified entity and flush and commit
- In future we may want to check for intermediate modifications of the entity by other users. I case a modification by someone else is detected the application will present a dialog to inform the user that someone else work will be overwritten. The dialog should present a table of all conflicting properties allowing the user to resolve the conflict. #7050
Related issues
Updated by Andreas Kohlbecker about 6 years ago
- Related to bug #6687: Multiple representations of the same entity merge problem added
Updated by Andreas Kohlbecker about 6 years ago
- Related to bug #7047: Vaadin UI and View scope beans are not always destroyed correctly added
Updated by Andreas Kohlbecker about 6 years ago
- Related to bug #7036: correctly release vaadin view resources when the browser windows has been closed added
Updated by Andreas Kohlbecker about 6 years ago
- Status changed from New to In Progress
- % Done changed from 0 to 40
Updated by Andreas Kohlbecker about 6 years ago
- Description updated (diff)
- Status changed from In Progress to Resolved
- Assignee changed from Andreas Kohlbecker to Fabian Reimeier
@Fabian: The refactoring is completed now. can you please do an in depth check on the distribution editor to confirm that nothing has been broke by these commits? All changes are in a feature branch which will be merged to develop once we know that there are no problems.
Updated by Andreas Kohlbecker about 6 years ago
Andreas Kohlbecker wrote:
@Fabian: The refactoring is completed now. can you please do an in depth check on the distribution editor to confirm that nothing has been broke by these commits? All changes are in a feature branch which will be merged to develop once we know that there are no problems.
I fixed some remaining problems and did a fast forward merge of the feature branch into develop. So you can test on develop directly.
Updated by Andreas Müller about 6 years ago
I have tested the distribution app intensively and couldn't find an problem, especially no LIE. Even after logout and login again. So maybe we can close this ticket.
Updated by Andreas Kohlbecker about 6 years ago
- Status changed from Resolved to Closed
- Assignee changed from Fabian Reimeier to Andreas Kohlbecker
Great thank you for this confirmation, i also could not produce any error. So i am closing this ticket now.