Class RepositoryEntityTypeManager

java.lang.Object
com.broadleafcommerce.common.jpa.RepositoryEntityTypeManager
All Implemented Interfaces:
org.springframework.core.Ordered, org.springframework.core.PriorityOrdered

public class RepositoryEntityTypeManager extends Object implements org.springframework.core.PriorityOrdered
Manager component for determining the overridden managed type of a repository. Overrides are informed by bean instances of JpaRepositoryEntityTypeOverride. If a override component is detected for the requested repository type, this component will return the overridden type. This information is generally used to refine the types of jpa entities retrieved from the datastore. This component can also be injected into custom repository implementations to help with result type refinement, when applicable.
Author:
Jeff Fischer
  • Constructor Details

    • RepositoryEntityTypeManager

      public RepositoryEntityTypeManager(@Nullable List<JpaRepositoryEntityTypeOverride> overrides, @Nullable Class<?> repoType, @Nullable Class<?> repoEntityClass, @Nullable javax.persistence.EntityManager em, @NonNull com.broadleafcommerce.common.extension.TypeFactory typeFactory, @NonNull com.broadleafcommerce.common.extension.projection.ProjectionFactory projectionFactory, @NonNull com.fasterxml.jackson.databind.ObjectMapper objectMapper)
    • RepositoryEntityTypeManager

      public RepositoryEntityTypeManager(@Nullable List<JpaRepositoryEntityTypeOverride> overrides, @Nullable com.broadleafcommerce.common.extension.projection.ProjectionFactory projectionFactory, @Nullable com.fasterxml.jackson.databind.ObjectMapper objectMapper)
  • Method Details

    • getOrder

      public int getOrder()
      Specified by:
      getOrder in interface org.springframework.core.Ordered
    • getManagedType

      @NonNull public <T> Class<T> getManagedType()
      Retrieve the type determined to be the managed type for this repository. May be a explicit type denoted by a JpaRepositoryEntityTypeOverride bean, or the default type declared in the repository definition. This method only applies to manager instances already directly tied to a repository (this is usually only the case with JpaTrackableRepository.
      Type Parameters:
      T - The repository managed type.
      Returns:
      The repository managed type.
    • getManagedType

      @NonNull public <T> Class<T> getManagedType(Class<?> repoType, Class<T> repoEntityClass, javax.persistence.EntityManager em)
      Retrieve the type determined to be the managed type for this repository. May be a explicit type denoted by a JpaRepositoryEntityTypeOverride bean, or the default type declared in the repository definition.
      Type Parameters:
      T - The calculated repository managed domain type.
      Parameters:
      repoType - The type of the JPA repository for which to determine the managed type.
      repoEntityClass - The domain type declared in the repository definition itself.
      em - The EntityManager instance associated with the repository.
      Returns:
      The calculated repository managed domain type.
    • getManagedType

      @NonNull public <T> Class<T> getManagedType(org.springframework.data.repository.Repository<?,?> repo, Class<T> repoEntityClass, javax.persistence.EntityManager em)
      Retrieve the type determined to be the managed type for this repository. May be a explicit type denoted by a JpaRepositoryEntityTypeOverride bean, or the default type declared in the repository definition.
      Type Parameters:
      T - The calculated repository managed domain type.
      Parameters:
      repo - The instance of the JPA repository for which to determine the managed type.
      repoEntityClass - The domain type declared in the repository definition itself.
      em - The EntityManager instance associated with the repository.
      Returns:
      The calculated repository managed domain type.
    • getAllManagedDomainsExtendingFromType

      public <T> List<Class<T>> getAllManagedDomainsExtendingFromType(Class<T> entityType, @NonNull @NonNull javax.persistence.EntityManager em)
      Goes through all of the managed types registered in the EntityManager and returns those extending from the given entityType.
      Type Parameters:
      T - the entity type to find extensions for
      Parameters:
      entityType - the entity type to find extensions for
      em - the entity manager
      Returns:
      all managed entities in the entity manager which extend from the given type (will include the given type itself if present)
    • getOverrides

      @Nullable public List<JpaRepositoryEntityTypeOverride> getOverrides()
    • getRepoType

      @Nullable public Class<?> getRepoType()
    • getRepoEntityClass

      @Nullable public Class<?> getRepoEntityClass()
    • getEm

      @Nullable public javax.persistence.EntityManager getEm()
    • getTypeFactory

      @Nullable public com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
    • getProjectionFactory

      @Nullable public com.broadleafcommerce.common.extension.projection.ProjectionFactory getProjectionFactory()
    • getObjectMapper

      @Nullable public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
    • getManagedTypeByRepo

      public Map<String,Class<?>> getManagedTypeByRepo()
    • getRegistration

      public com.broadleafcommerce.common.extension.projection.ProjectionManager getRegistration()
    • setRepoType

      public void setRepoType(@Nullable Class<?> repoType)
    • setRepoEntityClass

      public void setRepoEntityClass(@Nullable Class<?> repoEntityClass)
    • setEm

      public void setEm(@Nullable javax.persistence.EntityManager em)
    • setTypeFactory

      public void setTypeFactory(@Nullable com.broadleafcommerce.common.extension.TypeFactory typeFactory)
    • setProjectionFactory

      public void setProjectionFactory(@Nullable com.broadleafcommerce.common.extension.projection.ProjectionFactory projectionFactory)
    • setObjectMapper

      public void setObjectMapper(@Nullable com.fasterxml.jackson.databind.ObjectMapper objectMapper)
    • setManagedTypeByRepo

      public void setManagedTypeByRepo(Map<String,Class<?>> managedTypeByRepo)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setRegistration

      public void setRegistration(com.broadleafcommerce.common.extension.projection.ProjectionManager registration)