Package org.nuxeo.ecm.core.storage.sql
Class Fragment
java.lang.Object
org.nuxeo.ecm.core.storage.sql.Fragment
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
CollectionFragment
,SimpleFragment
A rich value corresponding to one row or a collection of rows in a table.
In addition to the basic Row
, this holds the old values (to check dirty state), the state and a reference to
the session.
This class has two kinds of state-changing methods:
- the "set" ones, which only change the state,
- the "mark" ones, which change the state and do the corresponding changes in the pristine/modified maps of the context.
- Author:
- Florent Guillaume
- See Also:
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected PersistenceContext
protected Serializable[]
The row old values, from the time of construction / refetch.protected Row
The row holding the data. -
Constructor Summary
ModifierConstructorDescriptionprotected
Fragment
(Row row, Fragment.State state, PersistenceContext context) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
accessed()
Checks that access to the fragment is possible.void
Clears the dirty state.getId()
Gets the id.abstract RowMapper.RowUpdate
Returns the row update to do in the database to write this value.getState()
Gets the state.protected void
Marks the fragment modified.protected abstract Fragment.State
refetch()
Refetches this fragment from the database.protected abstract Fragment.State
Resets the data for a fragment that was invalidated by deletion.protected void
setDeleted
(boolean primary) Marks the fragment deleted.protected void
Detaches the fragment from its persistence context.void
setId
(Serializable id) Sets the id.protected void
Sets the fragment in the "invalidated from a deletion" state.protected void
Sets the fragment in the "invalidated from a modification" state.protected void
Sets the (created/modified) fragment in the pristine state.toString()
-
Field Details
-
row
The row holding the data. -
oldvalues
The row old values, from the time of construction / refetch. The size of the the array is following#row.values.length
. -
context
-
-
Constructor Details
-
Fragment
- Parameters:
row
- the rowstate
- the initial state for the fragmentcontext
- the persistence context to which the fragment is tied, ornull
-
-
Method Details
-
getState
Gets the state.- Returns:
- the state
-
setId
Sets the id. This only used at most once to change a temporary id to the persistent one.- Parameters:
id
- the new persistent id
-
getId
Gets the id.- Returns:
- the id
-
clearDirty
public void clearDirty()Clears the dirty state. -
getRowUpdate
Returns the row update to do in the database to write this value.- Returns:
- a row update, or
null
if the value is unchanged since last clear - Since:
- 8.3
-
refetch
Refetches this fragment from the database. Needed when an invalidation has been received and the fragment is accessed again.- Returns:
- the new state,
Fragment.State.PRISTINE
orFragment.State.ABSENT
-
refetchDeleted
Resets the data for a fragment that was invalidated by deletion.- Returns:
- the new state,
Fragment.State.PRISTINE
orFragment.State.ABSENT
-
accessed
protected void accessed()Checks that access to the fragment is possible. Called internally before a get, so that invalidated fragments can be refetched. -
markModified
protected void markModified()Marks the fragment modified. Called internally after a put/set. -
setDeleted
protected void setDeleted(boolean primary) Marks the fragment deleted. Called after a remove. -
setDetached
protected void setDetached()Detaches the fragment from its persistence context. The caller makes sure that the fragment is removed from the context map. -
setPristine
protected void setPristine()Sets the (created/modified) fragment in the pristine state. Called after a save. -
setInvalidatedModified
protected void setInvalidatedModified()Sets the fragment in the "invalidated from a modification" state. This is called:- when a database operation does non-tracked changes, which means that on access a refetch will be needed,
- during post-commit invalidation.
-
setInvalidatedDeleted
protected void setInvalidatedDeleted()Sets the fragment in the "invalidated from a deletion" state. This is called:- when a database operation does a delete,
- during post-commit invalidation.
-
toString
-