Class SerializableEntityViewManager

java.lang.Object
com.blazebit.persistence.view.SerializableEntityViewManager
All Implemented Interfaces:
ServiceProvider, EntityViewManager, Serializable

public class SerializableEntityViewManager
extends Object
implements EntityViewManager, Serializable
A serializable entity view manager implementation that accesses the actual entity view manager through a static field in the entity view implementation class.
Since:
1.5.0
Author:
Christian Beikov
See Also:
Serialized Form
  • Field Details

  • Constructor Details

    • SerializableEntityViewManager

      public SerializableEntityViewManager​(Class<?> entityViewClass, EntityViewManager evm)
      Creates a new serializable entity view manager.
      Parameters:
      entityViewClass - The entity view class from which to access the entity view manager from
      evm - The transient entity view manager
  • Method Details

    • getMetamodel

      public ViewMetamodel getMetamodel()
      Description copied from interface: EntityViewManager
      Returns the metamodel for this entity view manager.
      Specified by:
      getMetamodel in interface EntityViewManager
      Returns:
      The metamodel for this entity view manager
    • getOptionalParameters

      public Map<String,​Object> getOptionalParameters()
      Description copied from interface: EntityViewManager
      Returns the globally configured optional parameters.
      Specified by:
      getOptionalParameters in interface EntityViewManager
      Returns:
      The optional parameters
    • find

      public <T> T find​(javax.persistence.EntityManager entityManager, Class<T> entityViewClass, Object entityId)
      Description copied from interface: EntityViewManager
      Loads and returns an entity view of the given type having the given entity id.
      Specified by:
      find in interface EntityViewManager
      Type Parameters:
      T - The type of the entity view class
      Parameters:
      entityManager - The entity manager to use for querying
      entityViewClass - The entity view class to use
      entityId - The id of the entity
      Returns:
      The loaded instance of the given entity view type with the id
    • find

      public <T> T find​(javax.persistence.EntityManager entityManager, EntityViewSetting<T,​CriteriaBuilder<T>> entityViewSetting, Object entityId)
      Description copied from interface: EntityViewManager
      Loads and returns an entity view as determined by the given type EntityViewSetting having the given entity id.
      Specified by:
      find in interface EntityViewManager
      Type Parameters:
      T - The type of the entity view class
      Parameters:
      entityManager - The entity manager to use for querying
      entityViewSetting - The entity view setting to use
      entityId - The id of the entity
      Returns:
      The loaded instance of the given entity view type with the id
    • getReference

      public <T> T getReference​(Class<T> entityViewClass, Object id)
      Description copied from interface: EntityViewManager
      Creates a reference instance of the entity view class for the given id and returns it.
      Specified by:
      getReference in interface EntityViewManager
      Type Parameters:
      T - The type of the entity view class
      Parameters:
      entityViewClass - The entity view class to construct
      id - The id of the entity view
      Returns:
      A reference instance of the given entity view type with the id
    • getEntityReference

      public <T> T getEntityReference​(javax.persistence.EntityManager entityManager, Object entityView)
      Description copied from interface: EntityViewManager
      Creates an entity reference for the given entity view and returns it.
      Specified by:
      getEntityReference in interface EntityViewManager
      Type Parameters:
      T - The type of the entity class
      Parameters:
      entityManager - The entity manager to use for the entity reference
      entityView - The entity view class for which to get the entity reference
      Returns:
      An entity reference for given entity view object
    • getChangeModel

      public <T> SingularChangeModel<T> getChangeModel​(T entityView)
      Description copied from interface: EntityViewManager
      Gives access to the change model of the entity view instance.
      Specified by:
      getChangeModel in interface EntityViewManager
      Type Parameters:
      T - The type of the given entity view
      Parameters:
      entityView - The entity view
      Returns:
      The change model of the entity view instance
    • create

      public <T> T create​(Class<T> entityViewClass)
      Description copied from interface: EntityViewManager
      Creates a new instance of the entity view class and returns it.
      Specified by:
      create in interface EntityViewManager
      Type Parameters:
      T - The type of the entity view class
      Parameters:
      entityViewClass - The entity view class to construct
      Returns:
      A new instance of the given entity view class
    • create

      public <T> T create​(Class<T> entityViewClass, Map<String,​Object> optionalParameters)
      Description copied from interface: EntityViewManager
      Creates a new instance of the entity view class and returns it.
      Specified by:
      create in interface EntityViewManager
      Type Parameters:
      T - The type of the entity view class
      Parameters:
      entityViewClass - The entity view class to construct
      optionalParameters - The optional parameters to consider
      Returns:
      A new instance of the given entity view class
    • createBuilder

      public <X> EntityViewBuilder<X> createBuilder​(Class<X> clazz)
      Description copied from interface: EntityViewManager
      Creates a builder for the entity view of the given class type.
      Specified by:
      createBuilder in interface EntityViewManager
      Type Parameters:
      X - The entity view type
      Parameters:
      clazz - The entity view type to build
      Returns:
      The builder
    • createBuilder

      public <X> EntityViewBuilder<X> createBuilder​(Class<X> clazz, String constructorName)
      Description copied from interface: EntityViewManager
      Creates a builder for the entity view of the given class type.
      Specified by:
      createBuilder in interface EntityViewManager
      Type Parameters:
      X - The entity view type
      Parameters:
      clazz - The entity view type to build
      constructorName - The entity view constructor to use
      Returns:
      The builder
    • createBuilder

      public <X> EntityViewBuilder<X> createBuilder​(X view)
      Description copied from interface: EntityViewManager
      Copies the state from the given view into a builder for the same entity view type.
      Specified by:
      createBuilder in interface EntityViewManager
      Type Parameters:
      X - The entity view type
      Parameters:
      view - The entity view to copy into a builder
      Returns:
      The builder
    • createBuilder

      public <X> EntityViewBuilder<X> createBuilder​(X view, String constructorName)
      Description copied from interface: EntityViewManager
      Copies the state from the given view into a builder for the same entity view type.
      Specified by:
      createBuilder in interface EntityViewManager
      Type Parameters:
      X - The entity view type
      Parameters:
      view - The entity view to copy into a builder
      constructorName - The entity view constructor to use
      Returns:
      The builder
    • createBuilder

      public <X> EntityViewBuilder<X> createBuilder​(Class<X> clazz, Map<String,​Object> optionalParameters)
      Description copied from interface: EntityViewManager
      Creates a builder for the entity view of the given class type.
      Specified by:
      createBuilder in interface EntityViewManager
      Type Parameters:
      X - The entity view type
      Parameters:
      clazz - The entity view type to build
      optionalParameters - The optional parameters to consider
      Returns:
      The builder
    • createBuilder

      public <X> EntityViewBuilder<X> createBuilder​(Class<X> clazz, Map<String,​Object> optionalParameters, String constructorName)
      Description copied from interface: EntityViewManager
      Creates a builder for the entity view of the given class type.
      Specified by:
      createBuilder in interface EntityViewManager
      Type Parameters:
      X - The entity view type
      Parameters:
      clazz - The entity view type to build
      optionalParameters - The optional parameters to consider
      constructorName - The entity view constructor to use
      Returns:
      The builder
    • createBuilder

      public <X> EntityViewBuilder<X> createBuilder​(X view, Map<String,​Object> optionalParameters)
      Description copied from interface: EntityViewManager
      Copies the state from the given view into a builder for the same entity view type.
      Specified by:
      createBuilder in interface EntityViewManager
      Type Parameters:
      X - The entity view type
      Parameters:
      view - The entity view to copy into a builder
      optionalParameters - The optional parameters to consider
      Returns:
      The builder
    • createBuilder

      public <X> EntityViewBuilder<X> createBuilder​(X view, Map<String,​Object> optionalParameters, String constructorName)
      Description copied from interface: EntityViewManager
      Copies the state from the given view into a builder for the same entity view type.
      Specified by:
      createBuilder in interface EntityViewManager
      Type Parameters:
      X - The entity view type
      Parameters:
      view - The entity view to copy into a builder
      optionalParameters - The optional parameters to consider
      constructorName - The entity view constructor to use
      Returns:
      The builder
    • convert

      public <T> T convert​(Object source, Class<T> entityViewClass, ConvertOption... convertOptions)
      Description copied from interface: EntityViewManager
      Creates a new instance of the entity view class, copies the values of matching attributes of the source object and returns the instance.
      Specified by:
      convert in interface EntityViewManager
      Type Parameters:
      T - The type of the entity view class
      Parameters:
      source - The source object from which to copy values
      entityViewClass - The entity view class to construct
      convertOptions - The options to use for converting
      Returns:
      A new instance of the given entity view class
    • convert

      public <T> T convert​(Object source, Class<T> entityViewClass, String constructorName, ConvertOption... convertOptions)
      Description copied from interface: EntityViewManager
      Creates a new instance of the entity view class, copies the values of matching attributes of the source object and returns the instance.
      Specified by:
      convert in interface EntityViewManager
      Type Parameters:
      T - The type of the entity view class
      Parameters:
      source - The source object from which to copy values
      entityViewClass - The entity view class to construct
      constructorName - The name of the entity view constructor to use
      convertOptions - The options to use for converting
      Returns:
      A new instance of the given entity view class
    • convert

      public <T> T convert​(Object source, Class<T> entityViewClass, Map<String,​Object> optionalParameters, ConvertOption... convertOptions)
      Description copied from interface: EntityViewManager
      Creates a new instance of the entity view class, copies the values of matching attributes of the source object and returns the instance.
      Specified by:
      convert in interface EntityViewManager
      Type Parameters:
      T - The type of the entity view class
      Parameters:
      source - The source object from which to copy values
      entityViewClass - The entity view class to construct
      optionalParameters - The optional parameters to consider
      convertOptions - The options to use for converting
      Returns:
      A new instance of the given entity view class
    • convert

      public <T> T convert​(Object source, Class<T> entityViewClass, String constructorName, Map<String,​Object> optionalParameters, ConvertOption... convertOptions)
      Description copied from interface: EntityViewManager
      Creates a new instance of the entity view class, copies the values of matching attributes of the source object and returns the instance.
      Specified by:
      convert in interface EntityViewManager
      Type Parameters:
      T - The type of the entity view class
      Parameters:
      source - The source object from which to copy values
      entityViewClass - The entity view class to construct
      constructorName - The name of the entity view constructor to use
      optionalParameters - The optional parameters to consider
      convertOptions - The options to use for converting
      Returns:
      A new instance of the given entity view class
    • convertWith

      public <T> ConvertOperationBuilder<T> convertWith​(Object source, Class<T> entityViewClass, ConvertOption... convertOptions)
      Description copied from interface: EntityViewManager
      Creates a new instance of the entity view class, copies the values of matching attributes of the source object and returns the instance.
      Specified by:
      convertWith in interface EntityViewManager
      Type Parameters:
      T - The type of the entity view class
      Parameters:
      source - The source object from which to copy values
      entityViewClass - The entity view class to construct
      convertOptions - The options to use for converting
      Returns:
      A builder to specify attribute entity view types and conversion options
    • convertWith

      public <T> ConvertOperationBuilder<T> convertWith​(Object source, Class<T> entityViewClass, String constructorName, ConvertOption... convertOptions)
      Description copied from interface: EntityViewManager
      Creates a new instance of the entity view class, copies the values of matching attributes of the source object and returns the instance.
      Specified by:
      convertWith in interface EntityViewManager
      Type Parameters:
      T - The type of the entity view class
      Parameters:
      source - The source object from which to copy values
      entityViewClass - The entity view class to construct
      constructorName - The name of the entity view constructor to use
      convertOptions - The options to use for converting
      Returns:
      A builder to specify attribute entity view types and conversion options
    • convertWith

      public <T> ConvertOperationBuilder<T> convertWith​(Object source, Class<T> entityViewClass, Map<String,​Object> optionalParameters, ConvertOption... convertOptions)
      Description copied from interface: EntityViewManager
      Creates a new instance of the entity view class, copies the values of matching attributes of the source object and returns the instance.
      Specified by:
      convertWith in interface EntityViewManager
      Type Parameters:
      T - The type of the entity view class
      Parameters:
      source - The source object from which to copy values
      entityViewClass - The entity view class to construct
      optionalParameters - The optional parameters to consider
      convertOptions - The options to use for converting
      Returns:
      A builder to specify attribute entity view types and conversion options
    • convertWith

      public <T> ConvertOperationBuilder<T> convertWith​(Object source, Class<T> entityViewClass, String constructorName, Map<String,​Object> optionalParameters, ConvertOption... convertOptions)
      Description copied from interface: EntityViewManager
      Creates a new instance of the entity view class, copies the values of matching attributes of the source object and returns the instance.
      Specified by:
      convertWith in interface EntityViewManager
      Type Parameters:
      T - The type of the entity view class
      Parameters:
      source - The source object from which to copy values
      entityViewClass - The entity view class to construct
      constructorName - The name of the entity view constructor to use
      optionalParameters - The optional parameters to consider
      convertOptions - The options to use for converting
      Returns:
      A builder to specify attribute entity view types and conversion options
    • save

      public void save​(javax.persistence.EntityManager entityManager, Object view)
      Description copied from interface: EntityViewManager
      Saves the entity which the given entity view maps to. Issues a partial update if enabled for the given view.
      Specified by:
      save in interface EntityViewManager
      Parameters:
      entityManager - The entity manager to use for the save
      view - The view to use for saving
    • saveFull

      public void saveFull​(javax.persistence.EntityManager entityManager, Object view)
      Description copied from interface: EntityViewManager
      Fully saves the entity which the given entity view maps to.
      Specified by:
      saveFull in interface EntityViewManager
      Parameters:
      entityManager - The entity manager to use for the save
      view - The view to use for saving
    • saveTo

      public void saveTo​(javax.persistence.EntityManager entityManager, Object view, Object entity)
      Description copied from interface: EntityViewManager
      Saves the entity view state onto the given entity. Issues a partial update if enabled for the given view.
      Specified by:
      saveTo in interface EntityViewManager
      Parameters:
      entityManager - The entity manager to use for the save
      view - The view to use for saving
      entity - The entity to apply data to
    • saveFullTo

      public void saveFullTo​(javax.persistence.EntityManager entityManager, Object view, Object entity)
      Description copied from interface: EntityViewManager
      Fully saves the entity view state onto the given entity.
      Specified by:
      saveFullTo in interface EntityViewManager
      Parameters:
      entityManager - The entity manager to use for the save
      view - The view to use for saving
      entity - The entity to apply data to
    • update

      @Deprecated public void update​(javax.persistence.EntityManager entityManager, Object view)
      Deprecated.
      Description copied from interface: EntityViewManager
      Updates the entity which the given entity view maps to. Issues a partial update if enabled for the given view.
      Specified by:
      update in interface EntityViewManager
      Parameters:
      entityManager - The entity manager to use for the update
      view - The view to use for updating
    • updateFull

      @Deprecated public void updateFull​(javax.persistence.EntityManager entityManager, Object view)
      Deprecated.
      Description copied from interface: EntityViewManager
      Fully updates the entity which the given entity view maps to.
      Specified by:
      updateFull in interface EntityViewManager
      Parameters:
      entityManager - The entity manager to use for the update
      view - The view to use for updating
    • saveWith

      public FlushOperationBuilder saveWith​(javax.persistence.EntityManager entityManager, Object view)
      Description copied from interface: EntityViewManager
      Saves the entity which the given entity view maps to. Issues a partial update if enabled for the given view.
      Specified by:
      saveWith in interface EntityViewManager
      Parameters:
      entityManager - The entity manager to use for the update
      view - The view to use for updating
      Returns:
      A flush operation builder for further configuring the flush operation
    • saveFullWith

      public FlushOperationBuilder saveFullWith​(javax.persistence.EntityManager entityManager, Object view)
      Description copied from interface: EntityViewManager
      Fully saves the entity which the given entity view maps to.
      Specified by:
      saveFullWith in interface EntityViewManager
      Parameters:
      entityManager - The entity manager to use for the update
      view - The view to use for updating
      Returns:
      A flush operation builder for further configuring the flush operation
    • saveWithTo

      public FlushOperationBuilder saveWithTo​(javax.persistence.EntityManager entityManager, Object view, Object entity)
      Description copied from interface: EntityViewManager
      Saves the entity view state onto the given entity. Issues a partial update if enabled for the given view.
      Specified by:
      saveWithTo in interface EntityViewManager
      Parameters:
      entityManager - The entity manager to use for the update
      view - The view to use for updating
      entity - The entity to apply data to
      Returns:
      A flush operation builder for further configuring the flush operation
    • saveFullWithTo

      public FlushOperationBuilder saveFullWithTo​(javax.persistence.EntityManager entityManager, Object view, Object entity)
      Description copied from interface: EntityViewManager
      Fully saves the entity view state onto the given entity.
      Specified by:
      saveFullWithTo in interface EntityViewManager
      Parameters:
      entityManager - The entity manager to use for the update
      view - The view to use for updating
      entity - The entity to apply data to
      Returns:
      A flush operation builder for further configuring the flush operation
    • remove

      public void remove​(javax.persistence.EntityManager entityManager, Object view)
      Description copied from interface: EntityViewManager
      Removes the entity represented by the given view. Also cascades deletes to attributes that have CascadeType.DELETE enabled.
      Specified by:
      remove in interface EntityViewManager
      Parameters:
      entityManager - The entity manager to use for the removing
      view - The view for which the entity should be removed
    • removeWith

      public FlushOperationBuilder removeWith​(javax.persistence.EntityManager entityManager, Object view)
      Description copied from interface: EntityViewManager
      Removes the entity represented by the given view. Also cascades deletes to attributes that have CascadeType.DELETE enabled.
      Specified by:
      removeWith in interface EntityViewManager
      Parameters:
      entityManager - The entity manager to use for the removing
      view - The view for which the entity should be removed
      Returns:
      A flush operation builder for further configuring the flush operation
    • remove

      public void remove​(javax.persistence.EntityManager entityManager, Class<?> entityViewClass, Object viewId)
      Description copied from interface: EntityViewManager
      Removes the entity represented by the entity type defiend for the given view and the given entity id. Also cascades deletes to attributes that have CascadeType.DELETE enabled.
      Specified by:
      remove in interface EntityViewManager
      Parameters:
      entityManager - The entity manager to use for the removing
      entityViewClass - The entity view class to use
      viewId - The id of entity view
    • removeWith

      public FlushOperationBuilder removeWith​(javax.persistence.EntityManager entityManager, Class<?> entityViewClass, Object viewId)
      Description copied from interface: EntityViewManager
      Removes the entity represented by the entity type defiend for the given view and the given entity id. Also cascades deletes to attributes that have CascadeType.DELETE enabled.
      Specified by:
      removeWith in interface EntityViewManager
      Parameters:
      entityManager - The entity manager to use for the removing
      entityViewClass - The entity view class to use
      viewId - The id of entity view
      Returns:
      A flush operation builder for further configuring the flush operation
    • applySetting

      public <T,​ Q extends FullQueryBuilder<T,​ Q>> Q applySetting​(EntityViewSetting<T,​Q> setting, CriteriaBuilder<?> criteriaBuilder)
      Description copied from interface: EntityViewManager
      Applies the entity view setting to the given criteria builder.
      Specified by:
      applySetting in interface EntityViewManager
      Type Parameters:
      T - The type of the entity view
      Q - PaginatedCriteriaBuilder if paginated, CriteriaBuilder otherwise
      Parameters:
      setting - The setting that should be applied
      criteriaBuilder - The criteria builder on which the setting should be applied
      Returns:
      PaginatedCriteriaBuilder if paginated, CriteriaBuilder otherwise
    • applySetting

      public <T,​ Q extends FullQueryBuilder<T,​ Q>> Q applySetting​(EntityViewSetting<T,​Q> setting, CriteriaBuilder<?> criteriaBuilder, String entityViewRoot)
      Description copied from interface: EntityViewManager
      Applies the entity view setting to the given entity view root of the criteria builder.
      Specified by:
      applySetting in interface EntityViewManager
      Type Parameters:
      T - The type of the entity view
      Q - PaginatedCriteriaBuilder if paginated, CriteriaBuilder otherwise
      Parameters:
      setting - The setting that should be applied
      criteriaBuilder - The criteria builder on which the setting should be applied
      entityViewRoot - The relation from which the entity view should be materialized
      Returns:
      PaginatedCriteriaBuilder if paginated, CriteriaBuilder otherwise
    • getService

      public <T> T getService​(Class<T> serviceClass)
      Specified by:
      getService in interface ServiceProvider