Pousse Café - Spring Data JPA

Pousse-Café is a framework assisting in writing DDD-based applications

License

License

GroupId

GroupId

org.pousse-cafe-framework
ArtifactId

ArtifactId

pousse-cafe-spring-jpa
Last Version

Last Version

0.6.0
Release Date

Release Date

Type

Type

jar
Description

Description

Pousse Café - Spring Data JPA
Pousse-Café is a framework assisting in writing DDD-based applications
Source Code Management

Source Code Management

http://github.com/pousse-cafe/pousse-cafe-spring-jpa

Download pousse-cafe-spring-jpa

How to add to project

<!-- https://jarcasting.com/artifacts/org.pousse-cafe-framework/pousse-cafe-spring-jpa/ -->
<dependency>
    <groupId>org.pousse-cafe-framework</groupId>
    <artifactId>pousse-cafe-spring-jpa</artifactId>
    <version>0.6.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.pousse-cafe-framework/pousse-cafe-spring-jpa/
implementation 'org.pousse-cafe-framework:pousse-cafe-spring-jpa:0.6.0'
// https://jarcasting.com/artifacts/org.pousse-cafe-framework/pousse-cafe-spring-jpa/
implementation ("org.pousse-cafe-framework:pousse-cafe-spring-jpa:0.6.0")
'org.pousse-cafe-framework:pousse-cafe-spring-jpa:jar:0.6.0'
<dependency org="org.pousse-cafe-framework" name="pousse-cafe-spring-jpa" rev="0.6.0">
  <artifact name="pousse-cafe-spring-jpa" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.pousse-cafe-framework', module='pousse-cafe-spring-jpa', version='0.6.0')
)
libraryDependencies += "org.pousse-cafe-framework" % "pousse-cafe-spring-jpa" % "0.6.0"
[org.pousse-cafe-framework/pousse-cafe-spring-jpa "0.6.0"]

Dependencies

provided (4)

Group / Artifact Type Version
org.pousse-cafe-framework : pousse-cafe-core jar 0.28.0
org.pousse-cafe-framework : pousse-cafe-spring jar 0.15.0
jakarta.persistence : jakarta.persistence-api jar 3.0.0
org.springframework.data : spring-data-jpa jar 2.4.3

test (1)

Group / Artifact Type Version
junit : junit jar 4.13.1

Project Modules

There are no modules declared in this project.

Travis build status Maven status

Pousse-Café Spring JPA

This storage plugin uses Spring Data JPA as its backend and is therefore able to store data into any JPA-supported database.

EntityAttributes implementations should be annotated using Java persistence annotations (i.e. @Entity, @Id, etc.).

JpaDataAccess expects subclasses to define jpaRepository method which must return a Spring Data JpaRepository. The convertId method must be defined in order to convert an aggregate's ID into a serializable object. In order to access the JpaRepository, simply autowire it in your data access.

Here is an example of data access implementation:

public class ExampleJpaDataAccess extends JpaDataAccess<ExampleId, ExampleData, String> implements ExampleDataAccess<ProductData> {

    @Override
    protected String convertId(ExampleId id) {
        return ...;
    }

    @Override
    protected JpaRepository<ExampleData, String> jpaRepository() {
        return repository;
    }

    @Autowired
    private ExampleDataMongoRepository repository;

    ...
}

Your Spring configuration class then looks like this (do not forget to include poussecafe.spring in your package scan):

@Configuration
@ComponentScan(basePackages = { "poussecafe.spring" })
public class AppConfiguration {

    @Bean
    public Bundles bundles(
            Messaging messaging,
            SpringJpaStorage storage) {
        MessagingAndStorage messagingAndStorage = new MessagingAndStorage(messaging, storage);
        return new Bundles.Builder()
            // Register your bundles here using withBundle and use messagingAndStorage
            // when building them
            .build();
    }
}

Configure your Spring Boot Maven project

Add the following snippet to your POM:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
    <groupId>org.pousse-cafe-framework</groupId>
    <artifactId>pousse-cafe-spring-jpa</artifactId>
    <version>${poussecafe.spring.jpa.version}</version>
</dependency>
<dependency>
    <groupId>org.pousse-cafe-framework</groupId>
    <artifactId>pousse-cafe-spring</artifactId>
    <version>${poussecafe.spring.version}</version>
</dependency>
<!--
    Put here the dependency to your preferred JDBC driver
-->
org.pousse-cafe-framework

Pousse-Café

Pousse-Café is a framework assisting you in writing applications following Domain Driven Design methodology

Versions

Version
0.6.0
0.5.0
0.4.0
0.3.0
0.2.0
0.1.0