Class DynamicEntityDaoImpl
java.lang.Object
org.broadleafcommerce.openadmin.server.dao.DynamicEntityDaoImpl
- All Implemented Interfaces:
DynamicEntityDao,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
@Component("blDynamicEntityDao")
@Scope("prototype")
public class DynamicEntityDaoImpl
extends Object
implements DynamicEntityDao, org.springframework.context.ApplicationContextAware
- Author:
- jfischer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.springframework.context.ApplicationContextprotected BasicFieldMetadataProviderprotected intprotected FieldMetadataProviderprotected DynamicDaoHelperprotected EntityConfigurationprotected FieldManagerprotected List<FieldMetadataProvider>protected longprotected Metadataprotected static final Map<String,Map<String, FieldMetadata>> Lifetime cache for the existence of DynamicEntityDaoImpl that just stores how many properties we have cached in METADATA_CACHE over the lifetime of the application.protected jakarta.persistence.EntityManagerprotected booleanWhether or not we should useMETADATA_CACHE_SIZESin the normal runtime of the application -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddClassToTree(Class<?> clazz, ClassTree tree) protected voidapplyForeignKeyPrecedence(ForeignKey foreignField, ForeignKey[] additionalForeignFields, Map<String, FieldMetadata> mergedProperties) protected voidapplyIncludesAndExcludes(String[] includeFields, String[] excludeFields, String prefix, Boolean isParentExcluded, Map<String, FieldMetadata> mergedProperties) protected voidbuildBasicProperty(Field field, Class<?> targetClass, ForeignKey foreignField, ForeignKey[] additionalForeignFields, String[] additionalNonPersistentProperties, MergedPropertyType mergedPropertyType, Map<String, FieldMetadata> presentationAttributes, List<org.hibernate.mapping.Property> componentProperties, Map<String, FieldMetadata> fields, String idProperty, Boolean populateManyToOneFields, String[] includeFields, String[] excludeFields, String configurationKey, String ceilingEntityFullyQualifiedClassname, List<Class<?>> parentClasses, String prefix, Boolean isParentExcluded, String propertyName, org.hibernate.type.Type type, boolean propertyForeignKey, int additionalForeignKeyIndexPosition, Boolean isComponentPrefix, String parentPrefix) protected voidbuildComponentProperties(Class<?> targetClass, ForeignKey foreignField, ForeignKey[] additionalForeignFields, String[] additionalNonPersistentProperties, MergedPropertyType mergedPropertyType, Map<String, FieldMetadata> fields, String idProperty, Boolean populateManyToOneFields, String[] includeFields, String[] excludeFields, String configurationKey, String ceilingEntityFullyQualifiedClassname, String propertyName, org.hibernate.type.Type type, Class<?> returnedClass, List<Class<?>> parentClasses, Boolean isParentExcluded, String prefix, String parentPrefix) protected voidbuildEntityProperties(Map<String, FieldMetadata> fields, ForeignKey foreignField, ForeignKey[] additionalForeignFields, String[] additionalNonPersistentProperties, Boolean populateManyToOneFields, String[] includeFields, String[] excludeFields, String configurationKey, String ceilingEntityFullyQualifiedClassname, String propertyName, Class<?> returnedClass, Class<?> targetClass, List<Class<?>> parentClasses, String prefix, Boolean isParentExcluded, String parentPrefix) protected voidbuildProperties(Class<?> targetClass, ForeignKey foreignField, ForeignKey[] additionalForeignFields, String[] additionalNonPersistentProperties, MergedPropertyType mergedPropertyType, Map<String, FieldMetadata> presentationAttributes, List<org.hibernate.mapping.Property> componentProperties, Map<String, FieldMetadata> fields, List<String> propertyNames, List<org.hibernate.type.Type> propertyTypes, String idProperty, Boolean populateManyToOneFields, String[] includeFields, String[] excludeFields, String configurationKey, String ceilingEntityFullyQualifiedClassname, List<Class<?>> parentClasses, String prefix, Boolean isParentExcluded, Boolean isComponentPrefix, String parentPrefix) protected voidbuildPropertiesFromPolymorphicEntities(Class<?>[] entities, ForeignKey foreignField, String[] additionalNonPersistentProperties, ForeignKey[] additionalForeignFields, MergedPropertyType mergedPropertyType, Boolean populateManyToOneFields, String[] includeFields, String[] excludeFields, String configurationKey, String ceilingEntityFullyQualifiedClassname, Map<String, FieldMetadata> mergedProperties, List<Class<?>> parentClasses, String prefix, Boolean isParentExcluded, String parentPrefix) voidclear()protected voidcreateClassTreeFromAnnotation(Class<?> clazz, ClassTree myTree) org.hibernate.CriteriacreateCriteria(Class<?> entityClass) voiddetach(Serializable entity) protected BooleandetermineExclusionForField(List<Class<?>> parentClasses, Class<?> targetClass, Field testField) protected intfindAdditionalForeignKeyIndex(ForeignKey[] additionalForeignFields, String prefix, String propertyName) voidflush()Field[]getAllFields(Class<?> targetClass) Class<?>[]getAllPolymorphicEntitiesFromCeiling(Class<?> ceilingClass) Class<?>[]getAllPolymorphicEntitiesFromCeiling(Class<?> ceilingClass, boolean includeUnqualifiedPolymorphicEntities) protected StringgetCacheKey(String ceilingEntityFullyQualifiedClassname, ForeignKey foreignField, String[] additionalNonPersistentProperties, ForeignKey[] additionalForeignFields, MergedPropertyType mergedPropertyType, Boolean populateManyToOneFields, Class<?> clazz, String configurationKey, Boolean isParentExcluded) Class<?>getCeilingImplClass(String className) getClassTree(Class<?>[] polymorphicClasses) getClassTreeFromCeiling(Class<?> ceilingClass) getFieldManager(boolean cleanFieldManager) getIdentifier(Object entity) Retrieve the identifier from the Hibernate entity (the entity must reside in the current session)protected FieldgetIdField(Class<?> clazz) getIdMetadata(Class<?> entityClass) Class<?>getImplClass(String className) getMergedProperties(Class<?> cls) Convenience method that obtains all of theMergedPropertyType.PRIMARYproperties for a given class.getMergedProperties(String ceilingEntityFullyQualifiedClassname, Class<?>[] entities, ForeignKey foreignField, String[] additionalNonPersistentProperties, ForeignKey[] additionalForeignFields, MergedPropertyType mergedPropertyType, Boolean populateManyToOneFields, String[] includeFields, String[] excludeFields, String configurationKey, String prefix) protected Map<String,FieldMetadata> getMergedPropertiesRecursively(String ceilingEntityFullyQualifiedClassname, Class<?>[] entities, ForeignKey foreignField, String[] additionalNonPersistentProperties, ForeignKey[] additionalForeignFields, MergedPropertyType mergedPropertyType, Boolean populateManyToOneFields, String[] includeFields, String[] excludeFields, String configurationKey, List<Class<?>> parentClasses, String prefix, Boolean isParentExcluded, String parentPrefix) org.hibernate.mapping.PersistentClassgetPersistentClass(String targetClassName) Get the Hibernate PersistentClass instance associated with the fully-qualified class name.protected Map<String,FieldMetadata> getPropertiesForEntityClass(Class<?> targetClass, ForeignKey foreignField, String[] additionalNonPersistentProperties, ForeignKey[] additionalForeignFields, MergedPropertyType mergedPropertyType, Boolean populateManyToOneFields, String[] includeFields, String[] excludeFields, String configurationKey, String ceilingEntityFullyQualifiedClassname, List<Class<?>> parentClasses, String prefix, Boolean isParentExcluded, String parentPrefix) getPropertiesForPrimitiveClass(String propertyName, String friendlyPropertyName, Class<?> targetClass, Class<?> parentClass, MergedPropertyType mergedPropertyType) getPropertyNames(Class<?> entityClass) List<org.hibernate.type.Type>getPropertyTypes(Class<?> entityClass) getSimpleMergedProperties(String entityName, PersistencePerspective persistencePerspective) jakarta.persistence.EntityManagerClass<?>[]getSuperClassHierarchy(Class<?> ceilingEntity) getTabAndGroupMetadata(Class<?>[] entities, ClassMetadata cmd) Class<?>[]getUpDownInheritance(Class<?> testClass) protected booleanisExcludeClassFromPolymorphism(Class<?> clazz) protected booleanisForeignKey(FieldMetadata fieldMetadata) <T> Tmerge(T entity) protected String<T> Tpersist(T entity) readOtherEntitiesWithPropertyValue(Serializable instance, String propertyName, String value) Returns a list of ids for entities that share the property value of the entity passed invoidrefresh(Serializable entity) voidvoidremove(Serializable entity) voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) voidsetDefaultFieldMetadataProvider(FieldMetadataProvider defaultFieldMetadataProvider) voidsetDynamicDaoHelper(DynamicDaoHelper dynamicDaoHelper) voidsetEntityConfiguration(EntityConfiguration entityConfiguration) protected voidsetExcludedBasedOnShowIfProperty(FieldMetadata fieldMetadata) voidsetFieldMetadataProviders(List<FieldMetadataProvider> fieldMetadataProviders) voidsetMetadata(Metadata metadata) protected voidsetOriginatingFieldForForeignKey(String propertyName, String key, FieldMetadata fieldMetadata) voidsetStandardEntityManager(jakarta.persistence.EntityManager entityManager) Class<?>[]sortEntities(Class<?> ceilingClass, List<Class<?>> entities) protected booleantestForeignProperty(ForeignKey foreignField, String prefix, String propertyName) protected BooleantestMultiLevelEmbeddableRecursion(String prefix, Boolean isComponentPrefix, String parentPrefix, String propertyName) testPropertyInclusion(FieldMetadata presentationAttribute) protected BooleantestPropertyRecursion(String prefix, List<Class<?>> parentClasses, String propertyName, Class<?> targetClass, String ceilingEntityFullyQualifiedClassname, Boolean isComponentPrefix, String parentPrefix) protected BooleantestStandardPropertyRecursion(String prefix, List<Class<?>> parentClasses, String propertyName, Class<?> targetClass, String ceilingEntityFullyQualifiedClassname, Boolean isComponentPrefix) booleanuseCache()
-
Field Details
-
METADATA_CACHE
-
METADATA_CACHE_SIZES
Lifetime cache for the existence of DynamicEntityDaoImpl that just stores how many properties we have cached in METADATA_CACHE over the lifetime of the application. This should survive evictions from METADATA_CACHE because it is for the purpose of diagnosing when we store different property counts in METADATA_CACHE as a result of cache eviction -
standardEntityManager
protected jakarta.persistence.EntityManager standardEntityManager -
metadata
-
entityConfiguration
-
fieldMetadataProviders
-
defaultFieldMetadataProvider
-
basicFieldMetadataProvider
-
propertyConfigurations
-
dynamicDaoHelper
-
cacheEntityMetaDataTtl
@Value("${cache.entity.dao.metadata.ttl}") protected int cacheEntityMetaDataTtl -
validateMetadataCacheSizes
@Value("${validate.metadata.cache.sizes:false}") protected boolean validateMetadataCacheSizesWhether or not we should useMETADATA_CACHE_SIZESin the normal runtime of the application -
lastCacheFlushTime
protected long lastCacheFlushTime -
applicationContext
protected org.springframework.context.ApplicationContext applicationContext -
fieldManager
-
-
Constructor Details
-
DynamicEntityDaoImpl
public DynamicEntityDaoImpl()
-
-
Method Details
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
-
createCriteria
- Specified by:
createCriteriain interfaceDynamicEntityDao
-
persist
public <T> T persist(T entity) - Specified by:
persistin interfaceDynamicEntityDao
-
find
- Specified by:
findin interfaceDynamicEntityDao
-
merge
public <T> T merge(T entity) - Specified by:
mergein interfaceDynamicEntityDao
-
flush
public void flush()- Specified by:
flushin interfaceDynamicEntityDao
-
detach
- Specified by:
detachin interfaceDynamicEntityDao
-
refresh
- Specified by:
refreshin interfaceDynamicEntityDao
-
retrieve
- Specified by:
retrievein interfaceDynamicEntityDao
-
remove
- Specified by:
removein interfaceDynamicEntityDao
-
clear
public void clear()- Specified by:
clearin interfaceDynamicEntityDao
-
getPersistentClass
Description copied from interface:DynamicEntityDaoGet the Hibernate PersistentClass instance associated with the fully-qualified class name. Will return null if no persistent class is associated with this name.- Specified by:
getPersistentClassin interfaceDynamicEntityDao- Returns:
- The PersistentClass instance
-
useCache
public boolean useCache()- Specified by:
useCachein interfaceDynamicEntityDao
-
getAllPolymorphicEntitiesFromCeiling
- Specified by:
getAllPolymorphicEntitiesFromCeilingin interfaceDynamicEntityDao
-
getAllPolymorphicEntitiesFromCeiling
public Class<?>[] getAllPolymorphicEntitiesFromCeiling(Class<?> ceilingClass, boolean includeUnqualifiedPolymorphicEntities) - Specified by:
getAllPolymorphicEntitiesFromCeilingin interfaceDynamicEntityDao
-
getUpDownInheritance
- Specified by:
getUpDownInheritancein interfaceDynamicEntityDao
-
getImplClass
- Specified by:
getImplClassin interfaceDynamicEntityDao
-
getCeilingImplClass
- Specified by:
getCeilingImplClassin interfaceDynamicEntityDao
-
readOtherEntitiesWithPropertyValue
public List<Long> readOtherEntitiesWithPropertyValue(Serializable instance, String propertyName, String value) Description copied from interface:DynamicEntityDaoReturns a list of ids for entities that share the property value of the entity passed in- Specified by:
readOtherEntitiesWithPropertyValuein interfaceDynamicEntityDao- Returns:
-
getIdentifier
Description copied from interface:DynamicEntityDaoRetrieve the identifier from the Hibernate entity (the entity must reside in the current session)- Specified by:
getIdentifierin interfaceDynamicEntityDao- Returns:
-
getIdField
-
sortEntities
-
addClassToTree
-
createClassTreeFromAnnotation
-
getClassTree
- Specified by:
getClassTreein interfaceDynamicEntityDao
-
getClassTreeFromCeiling
- Specified by:
getClassTreeFromCeilingin interfaceDynamicEntityDao
-
getSimpleMergedProperties
public Map<String,FieldMetadata> getSimpleMergedProperties(String entityName, PersistencePerspective persistencePerspective) - Specified by:
getSimpleMergedPropertiesin interfaceDynamicEntityDao
-
getMergedProperties
Description copied from interface:DynamicEntityDaoConvenience method that obtains all of theMergedPropertyType.PRIMARYproperties for a given class. Delegates toDynamicEntityDao.getMergedProperties(String, Class[], ForeignKey, String[], ForeignKey[], MergedPropertyType, Boolean, String[], String[], String, String)- Specified by:
getMergedPropertiesin interfaceDynamicEntityDao- Returns:
-
getMergedProperties
public Map<String,FieldMetadata> getMergedProperties(String ceilingEntityFullyQualifiedClassname, Class<?>[] entities, ForeignKey foreignField, String[] additionalNonPersistentProperties, ForeignKey[] additionalForeignFields, MergedPropertyType mergedPropertyType, Boolean populateManyToOneFields, String[] includeFields, String[] excludeFields, String configurationKey, String prefix) - Specified by:
getMergedPropertiesin interfaceDynamicEntityDao
-
getMergedPropertiesRecursively
protected Map<String,FieldMetadata> getMergedPropertiesRecursively(String ceilingEntityFullyQualifiedClassname, Class<?>[] entities, ForeignKey foreignField, String[] additionalNonPersistentProperties, ForeignKey[] additionalForeignFields, MergedPropertyType mergedPropertyType, Boolean populateManyToOneFields, String[] includeFields, String[] excludeFields, String configurationKey, List<Class<?>> parentClasses, String prefix, Boolean isParentExcluded, String parentPrefix) -
applyForeignKeyPrecedence
protected void applyForeignKeyPrecedence(ForeignKey foreignField, ForeignKey[] additionalForeignFields, Map<String, FieldMetadata> mergedProperties) -
applyIncludesAndExcludes
-
pad
-
getCacheKey
protected String getCacheKey(String ceilingEntityFullyQualifiedClassname, ForeignKey foreignField, String[] additionalNonPersistentProperties, ForeignKey[] additionalForeignFields, MergedPropertyType mergedPropertyType, Boolean populateManyToOneFields, Class<?> clazz, String configurationKey, Boolean isParentExcluded) -
buildPropertiesFromPolymorphicEntities
protected void buildPropertiesFromPolymorphicEntities(Class<?>[] entities, ForeignKey foreignField, String[] additionalNonPersistentProperties, ForeignKey[] additionalForeignFields, MergedPropertyType mergedPropertyType, Boolean populateManyToOneFields, String[] includeFields, String[] excludeFields, String configurationKey, String ceilingEntityFullyQualifiedClassname, Map<String, FieldMetadata> mergedProperties, List<Class<?>> parentClasses, String prefix, Boolean isParentExcluded, String parentPrefix) -
refreshDecimalDefaultValue
-
getAllFields
- Specified by:
getAllFieldsin interfaceDynamicEntityDao
-
getPropertiesForPrimitiveClass
public Map<String,FieldMetadata> getPropertiesForPrimitiveClass(String propertyName, String friendlyPropertyName, Class<?> targetClass, Class<?> parentClass, MergedPropertyType mergedPropertyType) - Specified by:
getPropertiesForPrimitiveClassin interfaceDynamicEntityDao
-
getIdMetadata
- Specified by:
getIdMetadatain interfaceDynamicEntityDao
-
getPropertyNames
- Specified by:
getPropertyNamesin interfaceDynamicEntityDao
-
getPropertyTypes
- Specified by:
getPropertyTypesin interfaceDynamicEntityDao
-
getTabAndGroupMetadata
- Specified by:
getTabAndGroupMetadatain interfaceDynamicEntityDao
-
getSuperClassHierarchy
-
getPropertiesForEntityClass
protected Map<String,FieldMetadata> getPropertiesForEntityClass(Class<?> targetClass, ForeignKey foreignField, String[] additionalNonPersistentProperties, ForeignKey[] additionalForeignFields, MergedPropertyType mergedPropertyType, Boolean populateManyToOneFields, String[] includeFields, String[] excludeFields, String configurationKey, String ceilingEntityFullyQualifiedClassname, List<Class<?>> parentClasses, String prefix, Boolean isParentExcluded, String parentPrefix) -
buildProperties
protected void buildProperties(Class<?> targetClass, ForeignKey foreignField, ForeignKey[] additionalForeignFields, String[] additionalNonPersistentProperties, MergedPropertyType mergedPropertyType, Map<String, FieldMetadata> presentationAttributes, List<org.hibernate.mapping.Property> componentProperties, Map<String, FieldMetadata> fields, List<String> propertyNames, List<org.hibernate.type.Type> propertyTypes, String idProperty, Boolean populateManyToOneFields, String[] includeFields, String[] excludeFields, String configurationKey, String ceilingEntityFullyQualifiedClassname, List<Class<?>> parentClasses, String prefix, Boolean isParentExcluded, Boolean isComponentPrefix, String parentPrefix) -
testPropertyInclusion
-
setExcludedBasedOnShowIfProperty
-
testPropertyRecursion
-
testMultiLevelEmbeddableRecursion
-
testStandardPropertyRecursion
-
determineExclusionForField
-
buildBasicProperty
protected void buildBasicProperty(Field field, Class<?> targetClass, ForeignKey foreignField, ForeignKey[] additionalForeignFields, String[] additionalNonPersistentProperties, MergedPropertyType mergedPropertyType, Map<String, FieldMetadata> presentationAttributes, List<org.hibernate.mapping.Property> componentProperties, Map<String, FieldMetadata> fields, String idProperty, Boolean populateManyToOneFields, String[] includeFields, String[] excludeFields, String configurationKey, String ceilingEntityFullyQualifiedClassname, List<Class<?>> parentClasses, String prefix, Boolean isParentExcluded, String propertyName, org.hibernate.type.Type type, boolean propertyForeignKey, int additionalForeignKeyIndexPosition, Boolean isComponentPrefix, String parentPrefix) -
testForeignProperty
-
findAdditionalForeignKeyIndex
protected int findAdditionalForeignKeyIndex(ForeignKey[] additionalForeignFields, String prefix, String propertyName) -
buildEntityProperties
protected void buildEntityProperties(Map<String, FieldMetadata> fields, ForeignKey foreignField, ForeignKey[] additionalForeignFields, String[] additionalNonPersistentProperties, Boolean populateManyToOneFields, String[] includeFields, String[] excludeFields, String configurationKey, String ceilingEntityFullyQualifiedClassname, String propertyName, Class<?> returnedClass, Class<?> targetClass, List<Class<?>> parentClasses, String prefix, Boolean isParentExcluded, String parentPrefix) -
isForeignKey
-
setOriginatingFieldForForeignKey
protected void setOriginatingFieldForForeignKey(String propertyName, String key, FieldMetadata fieldMetadata) -
buildComponentProperties
protected void buildComponentProperties(Class<?> targetClass, ForeignKey foreignField, ForeignKey[] additionalForeignFields, String[] additionalNonPersistentProperties, MergedPropertyType mergedPropertyType, Map<String, FieldMetadata> fields, String idProperty, Boolean populateManyToOneFields, String[] includeFields, String[] excludeFields, String configurationKey, String ceilingEntityFullyQualifiedClassname, String propertyName, org.hibernate.type.Type type, Class<?> returnedClass, List<Class<?>> parentClasses, Boolean isParentExcluded, String prefix, String parentPrefix) -
getStandardEntityManager
public jakarta.persistence.EntityManager getStandardEntityManager()- Specified by:
getStandardEntityManagerin interfaceDynamicEntityDao
-
setStandardEntityManager
public void setStandardEntityManager(jakarta.persistence.EntityManager entityManager) - Specified by:
setStandardEntityManagerin interfaceDynamicEntityDao
-
getFieldManager
- Specified by:
getFieldManagerin interfaceDynamicEntityDao
-
getFieldManager
- Specified by:
getFieldManagerin interfaceDynamicEntityDao
-
getEntityConfiguration
- Specified by:
getEntityConfigurationin interfaceDynamicEntityDao
-
setEntityConfiguration
- Specified by:
setEntityConfigurationin interfaceDynamicEntityDao
-
getMetadata
- Specified by:
getMetadatain interfaceDynamicEntityDao
-
setMetadata
- Specified by:
setMetadatain interfaceDynamicEntityDao
-
getFieldMetadataProviders
-
setFieldMetadataProviders
-
getDefaultFieldMetadataProvider
- Specified by:
getDefaultFieldMetadataProviderin interfaceDynamicEntityDao
-
setDefaultFieldMetadataProvider
-
isExcludeClassFromPolymorphism
-
getDynamicDaoHelper
- Specified by:
getDynamicDaoHelperin interfaceDynamicEntityDao
-
setDynamicDaoHelper
-