Typical Hibernate Object Life Cycle in a Web Application -?

Please describe the typical life cycle of a Hibernate object (which appears in the db table) in a web application. Suppose you create a new instance of an object and save it in db. But while the application is running, you will work on a separate object and, finally, you need to update it in the database, for example, upon exit. What does sleep mode and spring look like?

ps Can transactions and sessions live between servlet transitions? So, we opened 1 session and used it in all servlets without the need to re-open it?

I will try to give a descriptive example. Suppose that a log entry is created when the application starts. this can be done immediately, Log log = new Log (...), and then something like save (log) - log corresponds to the table log.

then, when the application processes user inputs and continues to move, new data accumulates.

and after the second step, we could add something to the journal object, for example, to the collection:

// now we have tracking of which user selected: Set thisUserChoice, // so we can update the permanent object, now we have new data! //log.userChoices = thisUserChoice.

This is where the nature of my question arises. How should we deal with this if we want to update the database whenever new data is received from the user?

, .

Hibernate .

? ?

+3
2

. . , .

- , . , , , , . , concurrency , . , concurrency .

Hibernate concurrency, , . JVM ...

hibernate documentation (, , ).

, - , , , (. 10.3), , , . . (.. ), . , , ( new), persist() save() (. 10.2). - , .

. (, session), , , update() (. 10.6). , .

Spring . Spring sessionFactory, . "spring hibernate tutorial", .

+3

Source: https://habr.com/ru/post/1737308/


All Articles