INNER CODE UNIT · Java

getCascadeClass

chaokunyang/jkes · jkes-boot/jkes-spring-data-jpa/src/main/java/com/timeyang/jkes/spring/jpa/EventSupport.java:332

    private Set<Class<?>> getCascadeClass(Class<?> domainClass, LinkedList<Class<?>> context) {
        Set<Class<?>> domainClassSet = new HashSet<>();

        // because jpa annotation is annotated on public method when annotated on method, so there is no need to use getDeclaredMethods and loop
        Method[] methods = domainClass.getMethods();
        for(Method method : methods) {
            CascadeType[] cascadeTypes = getCascadeTypes(method);

            if(cascadeTypes != null) {
                for(CascadeType cascadeType : cascadeTypes) {
                    if(cascadeType == CascadeType.ALL || cascadeType == CascadeType.REMOVE) {
                        // method return type may be List<xxx.XXX>, but what we need is xxx.XXX
                        Class<?> dClass = ReflectionUtils.getInnermostTypeClass(method);

                        if(!context.contains(dClass)) {
                            domainClassSet.add(dClass);
                        }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…