Update and saveorupdate

xiaoxiao2021-03-06  48

In the traditional JDO1.x, the PO only has two states. Once a PO is separated from PM, it is lost, it is no longer associated with the database data, and becomes a pure memory Vo, which even enters a new PM, Can't restore its state.

Hibernate is in that, after a PO is separated from session, it can also keep a state. After entering a new session, restore status management capabilities, but at this time, the status management needs to use session.Update or session.saveorupdate, this is "Requires a Slightly Different Programming Model" mentioned in Hibernate Reference

Simply, Update and SaveorUpdate are used to manage PO across the session.

Suppose your PO does not need to cross the session, then you don't need to use, for example, you open a session, do it, then turn it off, then this PO you will not use it, then you don't need to use Update.

And the meaning of session is that this PO object has been used as a VO after session, and then you have modified its properties outside, then you want to open a session, modify the property of VO Save to the database, then you need Update.

转载请注明原文地址:https://www.9cbs.com/read-115063.html

New Post(0)