Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

By default Spring uses Hibernate as the default JPA vendor. Although Hibernate is a good choice, some of us someone may prefer prefers to use EclipseLink as it was supposed to be the reference implementation for the Java Persistence JSR.
How configuring Spring-Boot to use EclipseLink as the JPA provider: https://blog.marcnuri.com/spring-data-jpa-eclipselink-configuring-spring-boot-to-use-eclipselink-as-the-jpa-provider/

...

The Spring Framework provides a consistent abstraction for transaction management. The Spring Framework’s declarative transaction management is made possible with Spring aspect-oriented programming (AOP), although, as the transactional aspects code comes with the Spring Framework distribution and may be used in a boilerplate fashion, AOP concepts do not generally have to be understood to make effective use of this code.

Source: https://docs.spring.io/spring-framework/docs/45.23.x7/spring-framework-reference/html/transactiondata-access.htmlhtml#transaction

Aspect-Oriented Programming

Aspect-Oriented Programming (AOP) complements Object-Oriented Programming (OOP) by providing another way of thinking about program structure. The key unit of modularity in OOP is the class, whereas in AOP the unit of modularity is the aspect. Aspects enable the modularization of concerns such as transaction management that cut across multiple types and objects. (Such concerns are often termed crosscutting concerns in AOP literature.)
One of the key components of Spring is the AOP framework. While the Spring IoC (Inversion of control) container does not depend on AOP, meaning you do not need to use AOP if you don’t want to, AOP complements Spring IoC to provide a very capable middleware solution.

Source: https://docs.spring.io/spring-framework/docs/45.3.15.RELEASE/spring-framework-7/reference/html/aopcore.htmlhtml#aop

Use a Higher-level Database Migration Tool

...

Using Spring Data JPA it needs to implement a repository for each model.
The goal of Spring Data repository abstraction is to significantly reduce the amount of boilerplate code required to implement data access layers for various persistence stores.

Source: https://docs.spring.io/spring-data/data-commons/docs/2.5.1/reference/html/#repositories

Code Block
languagejava
titleJpaToscaPropertyRepository
linenumberstrue
@Repository
public interface JpaToscaPropertyRepository extends JpaRepository<JpaToscaProperty, PfReferenceKey> {

}

...

Code Block
languagejava
titleControlLoopInstantiationProvider
linenumberstrue
@Service
public class ControlLoopInstantiationProvider {
    private final ControlLoopProvider controlLoopProvider;
    private final CommissioningProvider commissioningProvider;

    /**
     * Create a instantiation provider.
     *
     * @param databaseProviderParameters the parameters for database access
     */
    public ControlLoopInstantiationProvider(ControlLoopProvider controlLoopProvider,
            CommissioningProvider commissioningProvider) {
        this.controlLoopProvider = controlLoopProvider;
        this.commissioningProvider = commissioningProvider;
    }

    @Transactional
    public InstantiationResponse createControlLoops(ControlLoops controlLoops) throws PfModelException {
        for (ControlLoop controlLoop : controlLoops.getControlLoopList()) {
            ControlLoop checkControlLoop = controlLoopProvider.getControlLoop(controlLoop.getKey().asIdentifier());
            if (checkControlLoop != null) {
                throw new PfModelException(Response.Status.BAD_REQUEST,
                        controlLoop.getKey().asIdentifier() + " already defined");
            }
        }
        BeanValidationResult validationResult = validateControlLoops(controlLoops);
        if (!validationResult.isValid()) {
            throw new PfModelException(Response.Status.BAD_REQUEST, validationResult.getResult());
        }
        controlLoopProvider.createControlLoops(controlLoops.getControlLoopList());

        InstantiationResponse response = new InstantiationResponse();
        response.setAffectedControlLoops(controlLoops.getControlLoopList().stream()
                .map(cl -> cl.getKey().asIdentifier()).collect(Collectors.toList()));

        return response;
    }