Interface EntityViewManager

All Superinterfaces:
ServiceProvider
All Known Implementing Classes:
SerializableEntityViewManager

public interface EntityViewManager extends ServiceProvider
An interface that gives access to the metamodel and object builders.

There are currently limitations when it comes to using multiple instances of EntityViewManager simultaneously in an application. Specifically, multiple instances of EntityViewManager running within in the same class loader may not share entity view types. This is because the EntityViewManager dynamically creates proxy classes for entity view types and injects static self-references into these proxies. Another EntityViewManager creating a proxy for the same entity view type may find that the proxy class already exists within the class loader in which case it will overwrite the static self-references to point to itself leading to undefined behavior in the other EntityViewManager.

Since:
1.0.0
Author:
Christian Beikov
  • Method Details

    • getMetamodel

      ViewMetamodel getMetamodel()
      Returns the metamodel for this entity view manager.
      Returns:
      The metamodel for this entity view manager
    • getOptionalParameters

      Map<String,Object> getOptionalParameters()
      Returns the globally configured optional parameters.
      Returns:
      The optional parameters
      Since:
      1.5.0
    • find

      <T> T find(javax.persistence.EntityManager entityManager, Class<T> entityViewClass, Object entityId)
      Loads and returns an entity view of the given type having the given entity id.
      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
      Since:
      1.2.0
    • find

      <T> T find(javax.persistence.EntityManager entityManager, EntityViewSetting<T,CriteriaBuilder<T>> entityViewSetting, Object entityId)
      Loads and returns an entity view as determined by the given type EntityViewSetting having the given entity id.
      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
      Since:
      1.2.0
    • getReference

      <T> T getReference(Class<T> entityViewClass, Object id)
      Creates a reference instance of the entity view class for the given id and returns it.
      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
      Since:
      1.2.0
    • getEntityReference

      <T> T getEntityReference(javax.persistence.EntityManager entityManager, Object entityView)
      Creates an entity reference for the given entity view and returns it.
      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
      Since:
      1.3.0
    • getChangeModel

      <T> SingularChangeModel<T> getChangeModel(T entityView)
      Gives access to the change model of the entity view instance.
      Type Parameters:
      T - The type of the given entity view
      Parameters:
      entityView - The entity view
      Returns:
      The change model of the entity view instance
      Since:
      1.2.0
    • create

      <T> T create(Class<T> entityViewClass)
      Creates a new instance of the entity view class and returns it.
      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
      Since:
      1.2.0
    • create

      <T> T create(Class<T> entityViewClass, Map<String,Object> optionalParameters)
      Creates a new instance of the entity view class and returns it.
      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
      Since:
      1.5.0
    • createBuilder

      <X> EntityViewBuilder<X> createBuilder(Class<X> clazz)
      Creates a builder for the entity view of the given class type.
      Type Parameters:
      X - The entity view type
      Parameters:
      clazz - The entity view type to build
      Returns:
      The builder
      Since:
      1.5.0
    • createBuilder

      <X> EntityViewBuilder<X> createBuilder(Class<X> clazz, String constructorName)
      Creates a builder for the entity view of the given class type.
      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
      Since:
      1.5.0
    • createBuilder

      <X> EntityViewBuilder<X> createBuilder(X view)
      Copies the state from the given view into a builder for the same entity view type.
      Type Parameters:
      X - The entity view type
      Parameters:
      view - The entity view to copy into a builder
      Returns:
      The builder
      Since:
      1.5.0
    • createBuilder

      <X> EntityViewBuilder<X> createBuilder(X view, String constructorName)
      Copies the state from the given view into a builder for the same entity view type.
      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
      Since:
      1.5.0
    • createBuilder

      <X> EntityViewBuilder<X> createBuilder(Class<X> clazz, Map<String,Object> optionalParameters)
      Creates a builder for the entity view of the given class type.
      Type Parameters:
      X - The entity view type
      Parameters:
      clazz - The entity view type to build
      optionalParameters - The optional parameters to consider
      Returns:
      The builder
      Since:
      1.5.0
    • createBuilder

      <X> EntityViewBuilder<X> createBuilder(Class<X> clazz, Map<String,Object> optionalParameters, String constructorName)
      Creates a builder for the entity view of the given class type.
      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
      Since:
      1.5.0
    • createBuilder

      <X> EntityViewBuilder<X> createBuilder(X view, Map<String,Object> optionalParameters)
      Copies the state from the given view into a builder for the same entity view type.
      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
      Since:
      1.5.0
    • createBuilder

      <X> EntityViewBuilder<X> createBuilder(X view, Map<String,Object> optionalParameters, String constructorName)
      Copies the state from the given view into a builder for the same entity view type.
      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
      Since:
      1.5.0
    • convert

      <T> T convert(Object source, Class<T> entityViewClass, ConvertOption... convertOptions)
      Creates a new instance of the entity view class, copies the values of matching attributes of the source object and returns the instance.
      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
      Since:
      1.2.0
    • convert

      <T> T convert(Object source, Class<T> entityViewClass, String constructorName, ConvertOption... convertOptions)
      Creates a new instance of the entity view class, copies the values of matching attributes of the source object and returns the instance.
      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
      Since:
      1.5.0
    • convert

      <T> T convert(Object source, Class<T> entityViewClass, Map<String,Object> optionalParameters, ConvertOption... convertOptions)
      Creates a new instance of the entity view class, copies the values of matching attributes of the source object and returns the instance.
      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
      Since:
      1.5.0
    • convert

      <T> T convert(Object source, Class<T> entityViewClass, String constructorName, Map<String,Object> optionalParameters, ConvertOption... convertOptions)
      Creates a new instance of the entity view class, copies the values of matching attributes of the source object and returns the instance.
      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
      Since:
      1.5.0
    • convertWith

      <T> ConvertOperationBuilder<T> convertWith(Object source, Class<T> entityViewClass, ConvertOption... convertOptions)
      Creates a new instance of the entity view class, copies the values of matching attributes of the source object and returns the instance.
      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
      Since:
      1.4.0
    • convertWith

      <T> ConvertOperationBuilder<T> convertWith(Object source, Class<T> entityViewClass, String constructorName, ConvertOption... convertOptions)
      Creates a new instance of the entity view class, copies the values of matching attributes of the source object and returns the instance.
      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
      Since:
      1.5.0
    • convertWith

      <T> ConvertOperationBuilder<T> convertWith(Object source, Class<T> entityViewClass, Map<String,Object> optionalParameters, ConvertOption... convertOptions)
      Creates a new instance of the entity view class, copies the values of matching attributes of the source object and returns the instance.
      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
      Since:
      1.5.0
    • convertWith

      <T> ConvertOperationBuilder<T> convertWith(Object source, Class<T> entityViewClass, String constructorName, Map<String,Object> optionalParameters, ConvertOption... convertOptions)
      Creates a new instance of the entity view class, copies the values of matching attributes of the source object and returns the instance.
      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
      Since:
      1.5.0
    • save

      void save(javax.persistence.EntityManager entityManager, Object view)
      Saves the entity which the given entity view maps to. Issues a partial update if enabled for the given view.
      Parameters:
      entityManager - The entity manager to use for the save
      view - The view to use for saving
      Since:
      1.4.0
    • saveFull

      void saveFull(javax.persistence.EntityManager entityManager, Object view)
      Fully saves the entity which the given entity view maps to.
      Parameters:
      entityManager - The entity manager to use for the save
      view - The view to use for saving
      Since:
      1.4.0
    • saveTo

      void saveTo(javax.persistence.EntityManager entityManager, Object view, Object entity)
      Saves the entity view state onto the given entity. Issues a partial update if enabled for the given view.
      Parameters:
      entityManager - The entity manager to use for the save
      view - The view to use for saving
      entity - The entity to apply data to
      Since:
      1.4.0
    • saveFullTo

      void saveFullTo(javax.persistence.EntityManager entityManager, Object view, Object entity)
      Fully saves the entity view state onto the given entity.
      Parameters:
      entityManager - The entity manager to use for the save
      view - The view to use for saving
      entity - The entity to apply data to
      Since:
      1.4.0
    • update

      @Deprecated void update(javax.persistence.EntityManager entityManager, Object view)
      Deprecated.
      Use save(EntityManager, Object) instead. This will be removed in 2.0
      Updates the entity which the given entity view maps to. Issues a partial update if enabled for the given view.
      Parameters:
      entityManager - The entity manager to use for the update
      view - The view to use for updating
      Since:
      1.1.0
    • updateFull

      @Deprecated void updateFull(javax.persistence.EntityManager entityManager, Object view)
      Deprecated.
      Use saveFull(EntityManager, Object) instead. This will be removed in 2.0
      Fully updates the entity which the given entity view maps to.
      Parameters:
      entityManager - The entity manager to use for the update
      view - The view to use for updating
      Since:
      1.1.0
    • saveWith

      FlushOperationBuilder saveWith(javax.persistence.EntityManager entityManager, Object view)
      Saves the entity which the given entity view maps to. Issues a partial update if enabled for the given view.
      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
      Since:
      1.4.0
    • saveFullWith

      FlushOperationBuilder saveFullWith(javax.persistence.EntityManager entityManager, Object view)
      Fully saves the entity which the given entity view maps to.
      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
      Since:
      1.4.0
    • saveWithTo

      FlushOperationBuilder saveWithTo(javax.persistence.EntityManager entityManager, Object view, Object entity)
      Saves the entity view state onto the given entity. Issues a partial update if enabled for the given view.
      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
      Since:
      1.4.0
    • saveFullWithTo

      FlushOperationBuilder saveFullWithTo(javax.persistence.EntityManager entityManager, Object view, Object entity)
      Fully saves the entity view state onto the given entity.
      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
      Since:
      1.4.0
    • remove

      void remove(javax.persistence.EntityManager entityManager, Object view)
      Removes the entity represented by the given view. Also cascades deletes to attributes that have CascadeType.DELETE enabled.
      Parameters:
      entityManager - The entity manager to use for the removing
      view - The view for which the entity should be removed
      Since:
      1.2.0
    • removeWith

      FlushOperationBuilder removeWith(javax.persistence.EntityManager entityManager, Object view)
      Removes the entity represented by the given view. Also cascades deletes to attributes that have CascadeType.DELETE enabled.
      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
      Since:
      1.4.0
    • remove

      void remove(javax.persistence.EntityManager entityManager, Class<?> entityViewClass, Object viewId)
      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.
      Parameters:
      entityManager - The entity manager to use for the removing
      entityViewClass - The entity view class to use
      viewId - The id of entity view
      Since:
      1.2.0
    • removeWith

      FlushOperationBuilder removeWith(javax.persistence.EntityManager entityManager, Class<?> entityViewClass, Object viewId)
      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.
      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
      Since:
      1.4.0
    • applySetting

      <T, Q extends FullQueryBuilder<T, Q>> Q applySetting(EntityViewSetting<T,Q> setting, CriteriaBuilder<?> criteriaBuilder)
      Applies the entity view setting to the given criteria builder.
      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

      <T, Q extends FullQueryBuilder<T, Q>> Q applySetting(EntityViewSetting<T,Q> setting, CriteriaBuilder<?> criteriaBuilder, String entityViewRoot)
      Applies the entity view setting to the given entity view root of the criteria builder.
      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
      Since:
      1.2.0
    • close

      void close()
      Closes this EntityViewManager and frees resources. The behavior of any method called on an entity view manager after this method has been invoked is undefined.
      Since:
      1.6.10