Skip to content

v2.5.0 #220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
105d452
Update dependency com.puppycrawl.tools:checkstyle to v10.21.0
xdev-renovate Dec 13, 2024
ec586b6
Merge pull request #124 from xdev-software/renovate/com.puppycrawl.to…
AB-xdev Dec 16, 2024
73b158a
Update to latest checkstyle version
AB-xdev Dec 16, 2024
70052e6
Merge branch 'master' into update-from-template-merged
xdev-gh-bot Dec 17, 2024
faf4ca9
Merge pull request #212 from xdev-software/master
JohannesRabauer Dec 19, 2024
3f14ad2
Update org.springframework.boot.version to v3.4.1
xdev-renovate Dec 20, 2024
595bb3e
Merge pull request #213 from xdev-software/renovate/org.springframewo…
JohannesRabauer Dec 20, 2024
4f1cc86
Updated docs
JohannesRabauer Dec 20, 2024
6ba4ba3
Added more contraint tests
JohannesRabauer Dec 20, 2024
6499afd
Added documentation for validation-constraints
JohannesRabauer Dec 20, 2024
78a6794
Refactoring
JohannesRabauer Dec 20, 2024
072879a
Merge pull request #214 from xdev-software/jakarta.validation.constra…
JohannesRabauer Dec 20, 2024
f16525d
First try with implementing DataMigrator
JohannesRabauer Dec 20, 2024
851ddbf
Merge branch 'develop' into update-from-template-merged
xdev-gh-bot Dec 23, 2024
2de5958
Update net.sourceforge.pmd to v7.9.0
xdev-renovate Dec 28, 2024
e077430
Update dependency com.puppycrawl.tools:checkstyle to v10.21.1
xdev-renovate Dec 29, 2024
7f00a34
DataMigration basically working
JohannesRabauer Jan 7, 2025
8247d36
Update Micro-Migration Lib
JohannesRabauer Jan 7, 2025
706b340
Data Migration working
JohannesRabauer Jan 7, 2025
7528d8d
Made the DataMigrater optional
JohannesRabauer Jan 7, 2025
7742308
Update dependency software.xdev:micro-migration to v3
xdev-renovate Jan 8, 2025
8ffb798
Added multiple migration scripts tests
JohannesRabauer Jan 8, 2025
6e7773d
Improved Migration for non reflective scripts
JohannesRabauer Jan 8, 2025
2bd44ba
Added Docs / Cleanup
JohannesRabauer Jan 8, 2025
6db8d8c
Fix checkstyle
JohannesRabauer Jan 8, 2025
0e80868
Merge pull request #219 from xdev-software/micro-migration-for-developer
JohannesRabauer Jan 8, 2025
f4f0c9e
Merge pull request #217 from xdev-software/renovate/com.puppycrawl.to…
JohannesRabauer Jan 8, 2025
4496088
Merge pull request #216 from xdev-software/renovate/net.sourceforge.pmd
JohannesRabauer Jan 8, 2025
f3f83e7
Upgraded version to 2.5.0
JohannesRabauer Jan 8, 2025
d5621be
Merge branch 'develop' into renovate/software.xdev-micro-migration-3.x
JohannesRabauer Jan 8, 2025
723bb5c
Merge pull request #218 from xdev-software/renovate/software.xdev-mic…
JohannesRabauer Jan 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/checkstyle-idea.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 2.5.0

* Updated org.springframework.boot.version to v3.4.1
* Added support for the [micro-migration-Framework](https://github.com/xdev-software/micro-migration)

# 2.4.1

* Updated EclipseStore to v2.1.0
Expand All @@ -13,7 +18,6 @@

* Auto-Fix problems with adding ids to entities with existing data store.

~~~~
# 2.3.0

* Add support for shutting down the storage during application shutdown
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ instructions** are in the documentation](https://xdev-software.github.io/spring-
| ``2.0.0-2.1.0`` | ``17`` | ``3.3.2`` | ``1.4.0`` |
| ``2.2.0-2.3.1`` | ``17`` | ``3.3.4`` | ``1.4.0`` |
| ``2.4.0`` | ``17`` | ``3.4.0`` | ``2.0.0`` |
| ``>= 2.4.1`` | ``17`` | ``3.4.0`` | ``2.1.0`` |
| ``2.4.1`` | ``17`` | ``3.4.0`` | ``2.1.0`` |
| ``>= 2.5.0`` | ``17`` | ``3.4.1`` | ``2.1.0`` |

## Demo

Expand Down
6 changes: 3 additions & 3 deletions docs/antora.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: ROOT
title: Spring-Data-Eclipse-Store
version: master
display_version: '2.4.1'
display_version: '2.5.0'
start_page: index.adoc
nav:
- modules/ROOT/nav.adoc
asciidoc:
attributes:
product-name: 'Spring-Data-Eclipse-Store'
display-version: '2.4.1'
maven-version: '2.4.1'
display-version: '2.5.0'
maven-version: '2.5.0'
page-editable: false
page-out-of-support: false
4 changes: 3 additions & 1 deletion docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
** xref:features/queries.adoc[Queries]
** xref:features/transactions.adoc[Transactions]
** xref:features/versions.adoc[Versions]
** xref:features/versioned-migration.adoc[Versioned Migration]
** xref:features/rest-api.adoc[REST Interface]
* xref:migration.adoc[Migration from JPA]
** xref:features/validation-constraints.adoc[Validation Constraints]
* xref:migration-from-jpa.adoc[Migration from JPA]
* xref:known-issues.adoc[Known issues]
2 changes: 2 additions & 0 deletions docs/modules/ROOT/pages/features/features.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
* xref:features/queries.adoc[Queries]
* xref:features/transactions.adoc[Transactions]
* xref:features/versions.adoc[Versions]
* xref:features/versioned-migration.adoc[Versioned Migration]
* xref:features/rest-api.adoc[REST Interface]
* xref:features/validation-constraints.adoc[Validation Constraints]
19 changes: 19 additions & 0 deletions docs/modules/ROOT/pages/features/validation-constraints.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
= Validation Constraints

By using the https://jakarta.ee/learn/docs/jakartaee-tutorial/current/beanvalidation/bean-validation/bean-validation.html[Jakarta Bean Validation Constraints] developers with {product-name} can easily limit the allowed input of entities.
Here is a full list of supported validations: https://jakarta.ee/learn/docs/jakartaee-tutorial/current/beanvalidation/bean-validation/bean-validation.html#_using_jakarta_bean_validation_constraints[https://jakarta.ee/learn]

[source,java,title="https://github.com/xdev-software/spring-data-eclipse-store/blob/develop/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/complex/model/Person.java[Example from complex demo]"]
----
package software.xdev.spring.data.eclipse.store.demo.complex.model;

import jakarta.validation.constraints.NotBlank;

public class Person extends BaseEntity
{
@NotBlank
private String firstName;
//...
----

The ``jakarta.validation.Validator`` is provided by the https://github.com/xdev-software/spring-data-eclipse-store/tree/develop/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/config/EclipseStoreClientConfiguration.java[``EclipseStoreClientConfiguration``] and can be changed in the project-specific configuration.
116 changes: 116 additions & 0 deletions docs/modules/ROOT/pages/features/versioned-migration.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
= Versioned Migration

To keep the data in the store up-to-date, {product-name} utilizes https://github.com/xdev-software/micro-migration[XDEV's Micro-Migration].
This means the user can use versioning for the stored data and only apply changes for certain versions of data.
This can be very useful specifically with build-pipelines. https://github.com/xdev-software/micro-migration#intro[More info at Micro-Migration...]

== Implementation

This can be easily achieved by either of these 3 methods:

=== 1. Reflective Scripts

Simply implement a new component with a specific pattern of naming, that extends the ``ReflectiveDataMigrationScript``.

[source,java,title="https://github.com/xdev-software/spring-data-eclipse-store/blob/develop/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/complex/migration/v1_0_0_Init.java[Reflective example from complex demo]"]
----
package software.xdev.spring.data.eclipse.store.demo.complex.migration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
//...
import software.xdev.spring.data.eclipse.store.repository.root.data.version.ReflectiveDataMigrationScript;

@Component
public class v1_0_0_Init extends ReflectiveDataMigrationScript
{
private final OwnerService service;

@Autowired
public v1_0_0_Init(final OwnerService service)
{
this.service = service;
}

@Override
public void migrate(final Context<VersionedRoot, MigrationEmbeddedStorageManager> context)
{
this.service.createNewOwnerAndVisit("Mick", "Fleetwood", "Isabella");
}
}
----

Here the version number on which the data is updated on execution is derived from the class name.

The ``MigrationVersion`` is stored in the root object in the data store.
Therefore, the storage always knows on which version the current data is and the ``DataMigrater`` will only execute the newer scripts.

The scripts are automatically registered by declaring them as ``@Component``s.
That means that they can be anywhere as long as they are discovered by Spring as a component.

=== 2. Custom Scripts

Implementing a script without special naming is possible by implementing the
``DataMigrationScript``.

[source,java,title="https://github.com/xdev-software/spring-data-eclipse-store/blob/develop/spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/complex/migration/CustomNameScript.java[Custom script example from complex demo]"]
----
package software.xdev.spring.data.eclipse.store.demo.complex.migration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
//...
import software.xdev.spring.data.eclipse.store.repository.root.data.version.DataMigrationScript;

@Component
public class CustomNameScriptAddOwner implements DataMigrationScript
{
private final OwnerService service;

public CustomNameScriptAddOwner(@Autowired final OwnerService service)
{
this.service = service;
}

@Override
public MigrationVersion getTargetVersion()
{
return new MigrationVersion(1, 1, 0);
}

@Override
public void migrate(final Context<VersionedRoot, MigrationEmbeddedStorageManager> context)
{
this.service.createNewOwnerAndVisit("John", "McVie", "Ivan");
}
}
----

The version number must be returned explicitly in the ``#getTargetVersion``-method.

=== 3. Custom Migrater

If more customization is needed it is also possible to replace the ``DataMigrater`` completely and implement your own ``MicroMigrater``.
This should only be used if necessary since it adds a lot of complexity to the code.

[source,java,title="https://github.com/xdev-software/spring-data-eclipse-store/blob/develop/spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/data/migration/with/migrater/CustomMigrater.java[Custom migrater from tests]"]
----
package software.xdev.spring.data.eclipse.store.integration.isolated.tests.data.migration.with.migrater;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import software.xdev.micromigration.migrater.ExplicitMigrater;
import software.xdev.micromigration.migrater.MicroMigrater;
//...

@Component
public class CustomMigrater implements MicroMigrater
{
private final ExplicitMigrater explicitMigrater;

@Autowired
public CustomMigrater(final PersistedEntityRepository repository)
{
this.explicitMigrater = new ExplicitMigrater(new v1_0_0_Init(repository));
}
----
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>software.xdev</groupId>
<artifactId>spring-data-eclipse-store-root</artifactId>
<version>2.4.2-SNAPSHOT</version>
<version>2.5.0-SNAPSHOT</version>
<packaging>pom</packaging>

<organization>
Expand All @@ -22,7 +22,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<!-- Should be in sync with org.eclipse.store:integrations-spring-boot3 -->
<org.springframework.boot.version>3.4.0</org.springframework.boot.version>
<org.springframework.boot.version>3.4.1</org.springframework.boot.version>
<org.eclipse.store.version>2.1.0</org.eclipse.store.version>
<org.eclipse.serializer.version>2.1.0</org.eclipse.serializer.version>
<org.eclipse.storage-restservice-springboot.version>2.1.0</org.eclipse.storage-restservice-springboot.version>
Expand Down Expand Up @@ -107,7 +107,7 @@
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>10.21.0</version>
<version>10.21.1</version>
</dependency>
</dependencies>
<configuration>
Expand Down Expand Up @@ -150,12 +150,12 @@
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-core</artifactId>
<version>7.8.0</version>
<version>7.9.0</version>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-java</artifactId>
<version>7.8.0</version>
<version>7.9.0</version>
</dependency>
</dependencies>
</plugin>
Expand Down
4 changes: 2 additions & 2 deletions spring-data-eclipse-store-benchmark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<parent>
<groupId>software.xdev</groupId>
<artifactId>spring-data-eclipse-store-root</artifactId>
<version>2.4.2-SNAPSHOT</version>
<version>2.5.0-SNAPSHOT</version>
</parent>

<artifactId>spring-data-eclipse-store-benchmark</artifactId>
<version>2.4.2-SNAPSHOT</version>
<version>2.5.0-SNAPSHOT</version>
<packaging>jar</packaging>

<inceptionYear>2023</inceptionYear>
Expand Down
4 changes: 2 additions & 2 deletions spring-data-eclipse-store-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<parent>
<groupId>software.xdev</groupId>
<artifactId>spring-data-eclipse-store-root</artifactId>
<version>2.4.2-SNAPSHOT</version>
<version>2.5.0-SNAPSHOT</version>
</parent>

<artifactId>spring-data-eclipse-store-demo</artifactId>
<version>2.4.2-SNAPSHOT</version>
<version>2.5.0-SNAPSHOT</version>
<packaging>jar</packaging>

<organization>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ public void run(final String... args)
*/
private void ownerCalls()
{
this.ownerService.logOwners();
this.ownerService.deleteAll();
this.ownerService.logOwners();
this.ownerService.createNewOwnerAndVisit();
this.ownerService.createNewOwnerAndVisit("Stevie", "Nicks", "Peter");
this.ownerService.logOwnersAndVisits();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ public void logOwnersAndVisits()
/**
* Transactional
*/
public void createNewOwnerAndVisit()
public void createNewOwnerAndVisit(final String ownerFirstName, final String ownerLastName, final String petName)
{
new TransactionTemplate(this.transactionManager).execute(
status ->
{
final Owner owner = this.createOwner();
final Owner owner = this.createOwner(ownerFirstName, ownerLastName, petName);
this.ownerRepository.save(owner);

final Visit visit = this.createVisit();
owner.addVisit("Peter", visit);
owner.addVisit(petName, visit);
this.ownerRepository.save(owner);
LOG.info("----Stored new owner and visit----");
return null;
Expand All @@ -113,14 +113,14 @@ private Visit createVisit()
}

@SuppressWarnings("checkstyle:MagicNumber")
private Owner createOwner()
private Owner createOwner(final String ownerFirstName, final String ownerLastName, final String petName)
{
final Owner owner = new Owner();
owner.setFirstName("Stevie");
owner.setLastName("Nicks");
owner.setFirstName(ownerFirstName);
owner.setLastName(ownerLastName);
final Pet pet = new Pet();
pet.setBirthDate(LocalDate.now().minusWeeks(6));
pet.setName("Peter");
pet.setName(petName);
final PetType petType = new PetType();
petType.setName("Dog");
pet.setType(petType);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright © 2024 XDEV Software (https://xdev.software)
*
* Licensed 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 software.xdev.spring.data.eclipse.store.demo.complex.migration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import software.xdev.micromigration.eclipsestore.MigrationEmbeddedStorageManager;
import software.xdev.micromigration.scripts.Context;
import software.xdev.micromigration.version.MigrationVersion;
import software.xdev.spring.data.eclipse.store.demo.complex.OwnerService;
import software.xdev.spring.data.eclipse.store.repository.root.VersionedRoot;
import software.xdev.spring.data.eclipse.store.repository.root.data.version.DataMigrationScript;


/**
* This is automatically called by the
* {@link software.xdev.spring.data.eclipse.store.repository.root.data.version.DataMigrater} through dependency
* injection.
* <p>
* In contrast to {@link v1_0_0_Init} the version of this script is defined in the method {@link #getTargetVersion()}.
*/
@Component
public class CustomNameScript implements DataMigrationScript
{
private final OwnerService service;

public CustomNameScript(@Autowired final OwnerService service)
{
this.service = service;
}

@Override
public MigrationVersion getTargetVersion()
{
return new MigrationVersion(1, 1, 0);
}

@Override
public void migrate(final Context<VersionedRoot, MigrationEmbeddedStorageManager> context)
{
this.service.createNewOwnerAndVisit("John", "McVie", "Ivan");
}
}
Loading