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
public abstract class Fragment extends Object implements Serializable
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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Fragment.State
The possible states of a fragment.
-
Field Summary
Fields Modifier and Type Field Description protected PersistenceContext
context
protected Serializable[]
oldvalues
The row old values, from the time of construction / refetch.protected Row
row
The row holding the data.
-
Constructor Summary
Constructors Modifier Constructor Description protected
Fragment(Row row, Fragment.State state, PersistenceContext context)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
accessed()
Checks that access to the fragment is possible.void
clearDirty()
Clears the dirty state.Serializable
getId()
Gets the id.abstract RowMapper.RowUpdate
getRowUpdate()
Returns the row update to do in the database to write this value.Fragment.State
getState()
Gets the state.protected void
markModified()
Marks the fragment modified.protected abstract Fragment.State
refetch()
Refetches this fragment from the database.protected abstract Fragment.State
refetchDeleted()
Resets the data for a fragment that was invalidated by deletion.protected void
setDeleted(boolean primary)
Marks the fragment deleted.protected void
setDetached()
Detaches the fragment from its persistence context.void
setId(Serializable id)
Sets the id.protected void
setInvalidatedDeleted()
Sets the fragment in the "invalidated from a deletion" state.protected void
setInvalidatedModified()
Sets the fragment in the "invalidated from a modification" state.protected void
setPristine()
Sets the (created/modified) fragment in the pristine state.String
toString()
-
-
-
Field Detail
-
row
protected Row row
The row holding the data.
-
oldvalues
protected Serializable[] oldvalues
The row old values, from the time of construction / refetch. The size of the the array is following#row.values.length
.
-
context
protected PersistenceContext context
-
-
Constructor Detail
-
Fragment
protected Fragment(Row row, Fragment.State state, PersistenceContext context)
- Parameters:
row
- the rowstate
- the initial state for the fragmentcontext
- the persistence context to which the fragment is tied, ornull
-
-
Method Detail
-
getState
public Fragment.State getState()
Gets the state.- Returns:
- the state
-
setId
public void setId(Serializable id)
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
public Serializable getId()
Gets the id.- Returns:
- the id
-
clearDirty
public void clearDirty()
Clears the dirty state.
-
getRowUpdate
public abstract RowMapper.RowUpdate 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
protected abstract Fragment.State 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
protected abstract Fragment.State 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.
-
-