Class DeleteStatementGeneratorImpl
java.lang.Object
org.broadleafcommerce.core.util.service.DeleteStatementGeneratorImpl
- All Implemented Interfaces:
DeleteStatementGenerator
@Service("blDeleteStatementGenerator")
public class DeleteStatementGeneratorImpl
extends Object
implements DeleteStatementGenerator
The idea of this class if to iterate over props of the passed class and if found prop with annotation @OneToMany
recurse into it. In this way we build paths to the dependant classes. Once found "leaf" class that doesn't have
any more dependant entities it will start to go back and build path for that classes. In a result we will have
table name and path to that tabe from the root table, so we can build sql to delete dependencies in the right order.
It knows how to deal with @Embedded, bidirectional @OneToMany, @OneToMany through @JoinTable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddiveDeep(Class<?> classToProcess, String joinColumn, String mappedBy, Stack<DeleteStatementGeneratorImpl.PathElement> stack, Set<Class<?>> processedClasses, HashMap<String, DeleteStatementGeneratorImpl.OperationStackHolder> result, Map<String, List<DeleteStatementGeneratorImpl.PathElement>> dependencies, Set<String> exclusions, boolean fromManyToOne, Class prevProcessedClass) generateDeleteStatementsForType(Class<?> rootType, String rootTypeIdValue, Map<String, List<DeleteStatementGeneratorImpl.PathElement>> dependencies, Set<String> exclustions) protected StringgetSqls(String rootTypeIdValue, DeleteStatementGeneratorImpl.OperationStackHolder operationStackHolder) protected voidprocessField(Stack<DeleteStatementGeneratorImpl.PathElement> stack, Set<Class<?>> processedClasses, HashMap<String, DeleteStatementGeneratorImpl.OperationStackHolder> result, Field decl, Map<String, List<DeleteStatementGeneratorImpl.PathElement>> dependencies, Set<String> exclustions, boolean fromEmbedded, Class prevClassToProcess) protected voidprocessManualDefinedDependencies(Stack<DeleteStatementGeneratorImpl.PathElement> stack, HashMap<String, DeleteStatementGeneratorImpl.OperationStackHolder> result, Map<String, List<DeleteStatementGeneratorImpl.PathElement>> dependencies, String tableName)
-
Field Details
-
LOG
protected static final org.apache.commons.logging.Log LOG -
helper
protected org.broadleafcommerce.common.util.dao.DynamicDaoHelperImpl helper -
em
protected jakarta.persistence.EntityManager em
-
-
Constructor Details
-
DeleteStatementGeneratorImpl
public DeleteStatementGeneratorImpl()
-
-
Method Details
-
generateDeleteStatementsForType
public Map<String,String> generateDeleteStatementsForType(Class<?> rootType, String rootTypeIdValue, Map<String, List<DeleteStatementGeneratorImpl.PathElement>> dependencies, Set<String> exclustions) - Specified by:
generateDeleteStatementsForTypein interfaceDeleteStatementGenerator- Parameters:
rootType- type to start build sql dependency listrootTypeIdValue- value of id column of the rootType to be passed in where clausedependencies- - map of additional dependencies that can't be discovered during iteration from root type, key is table name to depend on like blc_order->some other table, value is structure representing dependant table, its PK, and FK to join with/exclustions- - Set with table name to exclude from list, like price_list, etc- Returns:
- a Map which key is a table name, and value is string with sql delete statement. This map is the LinkedHashMap so order of keys is important. You should exec sql from the beginning.
-
getSqls
protected String getSqls(String rootTypeIdValue, DeleteStatementGeneratorImpl.OperationStackHolder operationStackHolder) -
diveDeep
protected void diveDeep(Class<?> classToProcess, String joinColumn, String mappedBy, Stack<DeleteStatementGeneratorImpl.PathElement> stack, Set<Class<?>> processedClasses, HashMap<String, DeleteStatementGeneratorImpl.OperationStackHolder> result, Map<String, List<DeleteStatementGeneratorImpl.PathElement>> dependencies, Set<String> exclusions, boolean fromManyToOne, Class prevProcessedClass) -
processManualDefinedDependencies
protected void processManualDefinedDependencies(Stack<DeleteStatementGeneratorImpl.PathElement> stack, HashMap<String, DeleteStatementGeneratorImpl.OperationStackHolder> result, Map<String, List<DeleteStatementGeneratorImpl.PathElement>> dependencies, String tableName) -
processField
protected void processField(Stack<DeleteStatementGeneratorImpl.PathElement> stack, Set<Class<?>> processedClasses, HashMap<String, DeleteStatementGeneratorImpl.OperationStackHolder> result, Field decl, Map<String, List<DeleteStatementGeneratorImpl.PathElement>> dependencies, Set<String> exclustions, boolean fromEmbedded, Class prevClassToProcess)
-