[Log] hibernate persistence introduced

Hibernate is a transparent persistence mechanism
class does not know their own persistence capability,

Persistent life cycle
refers to the object in his experience of the life cycle status

Working unit
to a set of operations as a group of atoms

State of the object
Here Insert Picture Description

Transient object
using the new operator to instantiate the object does not immediately persistence,
their status is instantaneous transient
means not associated with any database table
once no longer referenced by other objects, the state immediately lost
non affairs, did not return roll function

Persistent objects
in the database entity instances exist identity to
mean persistence and hosted examples provided having its primary key identifier database
persistent object is always associated with the persistent context persistance context
caching them, and may detect whether they have been modified

Remove the object
was immediately removed from the database

Managed object
detached
after persistence, closed context, the application stored in the object handle handle
starved for state synchronization state is no longer guaranteed and the database
is no longer attached to the persistence context

Reattachment and merging may be used to handle this situation two operations

Persistence context
may be considered persistent context is managed entity instance a cache
EntityManager persistent context.
A unit of work in all instances persistent state and state are hosted cached in this context

  • Can automatically check and dirty affairs late write
    a modified object has not yet spread to the database is to be considered when dirty data
    using a transparent transaction-level write-behind, can spread as much as possible of the state changes to the database
  • It can be used as a persistence context cache
    repeatable read, if the database search would not return a hit
  • Warranty java object identity
  • The persistence context may extend across the entire conversation to
    hibernate can support the work of a possible long-running unit, called the dialogue to achieve a conversation
    Here Insert Picture Description

Here Insert Picture Description

Object identity ranges
are not identical persistence range substantially no guarantee that a row is accessed twice, and whether the same object instance will be returned to the application
to ensure persistence context in a single range, only one object instance represents a specific database row
process identity range, ensure that the entire process jvm only one instance of an object indicates that the line

Guess you like

Origin blog.csdn.net/java_sparrow/article/details/88982260