Class Fragment

  • All Implemented Interfaces:
    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.
    Florent Guillaume
    See Also:
    Serialized Form
    • Constructor Detail

      • Fragment

        protected Fragment​(Row row,
                           Fragment.State state,
                           PersistenceContext context)
        Constructs a Fragment from a Row.
        row - the row
        state - the initial state for the fragment
        context - the persistence context to which the fragment is tied, or null
    • Method Detail

      • setId

        public void setId​(Serializable id)
        Sets the id. This only used at most once to change a temporary id to the persistent one.
        id - the new persistent 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.
        a row update, or null if the value is unchanged since last clear
      • 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.