I know this is a subjective question, but why does Hibernate seem to be designed for short sessions? As a rule, in my applications I create a DAO to abstract the data layer, but since I cannot predict how entity objects will be used, some of its collections will be loaded lazy, or I must say that they do not load after the session is closed.
Why didn’t they design it so that it automatically resumed the session, or did sessions always remain open?
After you move out of the transaction boundary, you cannot get into the database again without starting a new transaction. Just in case long-term transactions are a bad thing (tm).
I think you want a lazy boot object from your view - look here for some options. I prefer to determine exactly which part of the feature map will be returned by my session processing methods. I find this facilitates unit test and performance testing of my business level.
I was working on a desktop application using EJB and Hibernate. We had to install lazy=falseeverywhere, because when objects become serialized, they lose the ability to be extracted from the backend. This is how it happens, unfortunately.
lazy=false
, , .
OpenSessionInView, ( ), , . , .
, .
- , , . , , , . , - - , , , .
MS ADO.NET, , , - , , , .
Hibernate . . . , , , , . , "" , , , .
If it were magical to resume sessions in non-webapps, I think that the complexity of learning the structure will greatly reduce the benefits.
Source: https://habr.com/ru/post/1697426/More articles:Is there a way to use XmlSiteMapProvider in a WinForm / Console / VSTest application? - unit-testingProcess coordination in mod_perl under working MPM - multithreadingДанные виджетов через несколько контроллеров - rubyShould I use Wap for a cellular web page? - websiteShell script for recursive directory lookup and line replacement - scriptingSQL Server Adapter for Rails - windowscompression library for c and php - cCalculation of matrix pseudo-inversion in C ++ - c ++Веб-службы или пользовательский протокол? - web-applicationsКак сделать Ajax.Autocompleter выполнить запрос без ввода? - javascriptAll Articles