adamsaghy commented on code in PR #5143: URL: https://github.com/apache/fineract/pull/5143#discussion_r2495899144
########## fineract-core/src/main/java/org/apache/fineract/infrastructure/core/aop/FlushModeAspect.java: ########## @@ -0,0 +1,71 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.infrastructure.core.aop; + +import jakarta.persistence.FlushModeType; +import lombok.RequiredArgsConstructor; +import org.apache.fineract.infrastructure.core.annotation.WithFlushMode; +import org.apache.fineract.infrastructure.core.persistence.FlushModeHandler; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.reflect.MethodSignature; +import org.springframework.core.annotation.AnnotationUtils; +import org.springframework.stereotype.Component; + +/** + * Aspect that handles the @WithFlushMode annotation to manage JPA flush mode around method execution. + */ +@Aspect +@Component +@RequiredArgsConstructor +public class FlushModeAspect { + + private final FlushModeHandler flushModeHandler; + + @Around("@within(withFlushMode) || @annotation(withFlushMode)") + public Object manageFlushMode(ProceedingJoinPoint joinPoint, WithFlushMode withFlushMode) { Review Comment: I accept the transactionSynchronizationManager one, but i dont think we should mess with the orders. In case "Transactional" annotation is used alongside with WithFlushMode, the only important to use Transactional first. By default Transactional annotation is using Spring default ordering which is LOWEST_PRECEDENCE, alongside with Retry, Cacheable, etc. which also using this. If i am changing it to use LOWEST_PRECEDENCE-1, it might break all those logic. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
