Package com.broadleafcommerce.common.jpa
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
-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorDescriptionRepositoryEntityTypeManager
(List<JpaRepositoryEntityTypeOverride> overrides, com.broadleafcommerce.common.extension.projection.ProjectionFactory projectionFactory, com.fasterxml.jackson.databind.ObjectMapper objectMapper) RepositoryEntityTypeManager
(List<JpaRepositoryEntityTypeOverride> overrides, Class<?> repoType, Class<?> repoEntityClass, jakarta.persistence.EntityManager em, com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.broadleafcommerce.common.extension.projection.ProjectionFactory projectionFactory, com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
boolean
getAllManagedDomainsExtendingFromType
(Class<T> entityType, @NonNull jakarta.persistence.EntityManager em) Goes through all of the managed types registered in theEntityManager
and returns those extending from the givenentityType
.jakarta.persistence.EntityManager
getEm()
<T> Class<T>
Retrieve the type determined to be the managed type for this repository.<T> Class<T>
getManagedType
(Class<?> repoType, Class<T> repoEntityClass, jakarta.persistence.EntityManager em) Retrieve the type determined to be the managed type for this repository.<T> Class<T>
getManagedType
(org.springframework.data.repository.Repository<?, ?> repo, Class<T> repoEntityClass, jakarta.persistence.EntityManager em) Retrieve the type determined to be the managed type for this repository.com.fasterxml.jackson.databind.ObjectMapper
int
getOrder()
com.broadleafcommerce.common.extension.projection.ProjectionFactory
com.broadleafcommerce.common.extension.projection.ProjectionManager
Class<?>
Class<?>
com.broadleafcommerce.common.extension.TypeFactory
int
hashCode()
void
setEm
(jakarta.persistence.EntityManager em) void
setManagedTypeByRepo
(Map<String, Class<?>> managedTypeByRepo) void
setObjectMapper
(com.fasterxml.jackson.databind.ObjectMapper objectMapper) void
setProjectionFactory
(com.broadleafcommerce.common.extension.projection.ProjectionFactory projectionFactory) void
setRegistration
(com.broadleafcommerce.common.extension.projection.ProjectionManager registration) void
setRepoEntityClass
(Class<?> repoEntityClass) void
setRepoType
(Class<?> repoType) void
setTypeFactory
(com.broadleafcommerce.common.extension.TypeFactory typeFactory) toString()
-
Constructor Details
-
RepositoryEntityTypeManager
public RepositoryEntityTypeManager(@Nullable List<JpaRepositoryEntityTypeOverride> overrides, @Nullable Class<?> repoType, @Nullable Class<?> repoEntityClass, @Nullable jakarta.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 interfaceorg.springframework.core.Ordered
-
getManagedType
Retrieve the type determined to be the managed type for this repository. May be a explicit type denoted by aJpaRepositoryEntityTypeOverride
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, jakarta.persistence.EntityManager em) Retrieve the type determined to be the managed type for this repository. May be a explicit type denoted by aJpaRepositoryEntityTypeOverride
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, jakarta.persistence.EntityManager em) Retrieve the type determined to be the managed type for this repository. May be a explicit type denoted by aJpaRepositoryEntityTypeOverride
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 jakarta.persistence.EntityManager em) Goes through all of the managed types registered in theEntityManager
and returns those extending from the givenentityType
.- Type Parameters:
T
- the entity type to find extensions for- Parameters:
entityType
- the entity type to find extensions forem
- 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
-
getRepoType
-
getRepoEntityClass
-
getEm
@Nullable public jakarta.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
-
getRegistration
public com.broadleafcommerce.common.extension.projection.ProjectionManager getRegistration() -
setRepoType
-
setRepoEntityClass
-
setEm
public void setEm(@Nullable jakarta.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
-
equals
-
canEqual
-
hashCode
public int hashCode() -
toString
-
setRegistration
public void setRegistration(com.broadleafcommerce.common.extension.projection.ProjectionManager registration)
-