Skip to content

Commit f7cd923

Browse files
Merge pull request #220 from xdev-software/develop
v2.5.0
2 parents a3ae749 + 723bb5c commit f7cd923

File tree

55 files changed

+1841
-70
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1841
-70
lines changed

.idea/checkstyle-idea.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 2.5.0
2+
3+
* Updated org.springframework.boot.version to v3.4.1
4+
* Added support for the [micro-migration-Framework](https://github.com/xdev-software/micro-migration)
5+
16
# 2.4.1
27

38
* Updated EclipseStore to v2.1.0
@@ -13,7 +18,6 @@
1318

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

16-
~~~~
1721
# 2.3.0
1822

1923
* Add support for shutting down the storage during application shutdown

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ instructions** are in the documentation](https://xdev-software.github.io/spring-
5858
| ``2.0.0-2.1.0`` | ``17`` | ``3.3.2`` | ``1.4.0`` |
5959
| ``2.2.0-2.3.1`` | ``17`` | ``3.3.4`` | ``1.4.0`` |
6060
| ``2.4.0`` | ``17`` | ``3.4.0`` | ``2.0.0`` |
61-
| ``>= 2.4.1`` | ``17`` | ``3.4.0`` | ``2.1.0`` |
61+
| ``2.4.1`` | ``17`` | ``3.4.0`` | ``2.1.0`` |
62+
| ``>= 2.5.0`` | ``17`` | ``3.4.1`` | ``2.1.0`` |
6263

6364
## Demo
6465

docs/antora.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
name: ROOT
22
title: Spring-Data-Eclipse-Store
33
version: master
4-
display_version: '2.4.1'
4+
display_version: '2.5.0'
55
start_page: index.adoc
66
nav:
77
- modules/ROOT/nav.adoc
88
asciidoc:
99
attributes:
1010
product-name: 'Spring-Data-Eclipse-Store'
11-
display-version: '2.4.1'
12-
maven-version: '2.4.1'
11+
display-version: '2.5.0'
12+
maven-version: '2.5.0'
1313
page-editable: false
1414
page-out-of-support: false

docs/modules/ROOT/nav.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
** xref:features/queries.adoc[Queries]
99
** xref:features/transactions.adoc[Transactions]
1010
** xref:features/versions.adoc[Versions]
11+
** xref:features/versioned-migration.adoc[Versioned Migration]
1112
** xref:features/rest-api.adoc[REST Interface]
12-
* xref:migration.adoc[Migration from JPA]
13+
** xref:features/validation-constraints.adoc[Validation Constraints]
14+
* xref:migration-from-jpa.adoc[Migration from JPA]
1315
* xref:known-issues.adoc[Known issues]

docs/modules/ROOT/pages/features/features.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@
55
* xref:features/queries.adoc[Queries]
66
* xref:features/transactions.adoc[Transactions]
77
* xref:features/versions.adoc[Versions]
8+
* xref:features/versioned-migration.adoc[Versioned Migration]
89
* xref:features/rest-api.adoc[REST Interface]
10+
* xref:features/validation-constraints.adoc[Validation Constraints]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
= Validation Constraints
2+
3+
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.
4+
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]
5+
6+
[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]"]
7+
----
8+
package software.xdev.spring.data.eclipse.store.demo.complex.model;
9+
10+
import jakarta.validation.constraints.NotBlank;
11+
12+
public class Person extends BaseEntity
13+
{
14+
@NotBlank
15+
private String firstName;
16+
//...
17+
----
18+
19+
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.
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
= Versioned Migration
2+
3+
To keep the data in the store up-to-date, {product-name} utilizes https://github.com/xdev-software/micro-migration[XDEV's Micro-Migration].
4+
This means the user can use versioning for the stored data and only apply changes for certain versions of data.
5+
This can be very useful specifically with build-pipelines. https://github.com/xdev-software/micro-migration#intro[More info at Micro-Migration...]
6+
7+
== Implementation
8+
9+
This can be easily achieved by either of these 3 methods:
10+
11+
=== 1. Reflective Scripts
12+
13+
Simply implement a new component with a specific pattern of naming, that extends the ``ReflectiveDataMigrationScript``.
14+
15+
[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]"]
16+
----
17+
package software.xdev.spring.data.eclipse.store.demo.complex.migration;
18+
19+
import org.springframework.beans.factory.annotation.Autowired;
20+
import org.springframework.stereotype.Component;
21+
//...
22+
import software.xdev.spring.data.eclipse.store.repository.root.data.version.ReflectiveDataMigrationScript;
23+
24+
@Component
25+
public class v1_0_0_Init extends ReflectiveDataMigrationScript
26+
{
27+
private final OwnerService service;
28+
29+
@Autowired
30+
public v1_0_0_Init(final OwnerService service)
31+
{
32+
this.service = service;
33+
}
34+
35+
@Override
36+
public void migrate(final Context<VersionedRoot, MigrationEmbeddedStorageManager> context)
37+
{
38+
this.service.createNewOwnerAndVisit("Mick", "Fleetwood", "Isabella");
39+
}
40+
}
41+
----
42+
43+
Here the version number on which the data is updated on execution is derived from the class name.
44+
45+
The ``MigrationVersion`` is stored in the root object in the data store.
46+
Therefore, the storage always knows on which version the current data is and the ``DataMigrater`` will only execute the newer scripts.
47+
48+
The scripts are automatically registered by declaring them as ``@Component``s.
49+
That means that they can be anywhere as long as they are discovered by Spring as a component.
50+
51+
=== 2. Custom Scripts
52+
53+
Implementing a script without special naming is possible by implementing the
54+
``DataMigrationScript``.
55+
56+
[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]"]
57+
----
58+
package software.xdev.spring.data.eclipse.store.demo.complex.migration;
59+
60+
import org.springframework.beans.factory.annotation.Autowired;
61+
import org.springframework.stereotype.Component;
62+
//...
63+
import software.xdev.spring.data.eclipse.store.repository.root.data.version.DataMigrationScript;
64+
65+
@Component
66+
public class CustomNameScriptAddOwner implements DataMigrationScript
67+
{
68+
private final OwnerService service;
69+
70+
public CustomNameScriptAddOwner(@Autowired final OwnerService service)
71+
{
72+
this.service = service;
73+
}
74+
75+
@Override
76+
public MigrationVersion getTargetVersion()
77+
{
78+
return new MigrationVersion(1, 1, 0);
79+
}
80+
81+
@Override
82+
public void migrate(final Context<VersionedRoot, MigrationEmbeddedStorageManager> context)
83+
{
84+
this.service.createNewOwnerAndVisit("John", "McVie", "Ivan");
85+
}
86+
}
87+
----
88+
89+
The version number must be returned explicitly in the ``#getTargetVersion``-method.
90+
91+
=== 3. Custom Migrater
92+
93+
If more customization is needed it is also possible to replace the ``DataMigrater`` completely and implement your own ``MicroMigrater``.
94+
This should only be used if necessary since it adds a lot of complexity to the code.
95+
96+
[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]"]
97+
----
98+
package software.xdev.spring.data.eclipse.store.integration.isolated.tests.data.migration.with.migrater;
99+
100+
import org.springframework.beans.factory.annotation.Autowired;
101+
import org.springframework.stereotype.Component;
102+
import software.xdev.micromigration.migrater.ExplicitMigrater;
103+
import software.xdev.micromigration.migrater.MicroMigrater;
104+
//...
105+
106+
@Component
107+
public class CustomMigrater implements MicroMigrater
108+
{
109+
private final ExplicitMigrater explicitMigrater;
110+
111+
@Autowired
112+
public CustomMigrater(final PersistedEntityRepository repository)
113+
{
114+
this.explicitMigrater = new ExplicitMigrater(new v1_0_0_Init(repository));
115+
}
116+
----

pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>software.xdev</groupId>
88
<artifactId>spring-data-eclipse-store-root</artifactId>
9-
<version>2.4.2-SNAPSHOT</version>
9+
<version>2.5.0-SNAPSHOT</version>
1010
<packaging>pom</packaging>
1111

1212
<organization>
@@ -22,7 +22,7 @@
2222
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
2323

2424
<!-- Should be in sync with org.eclipse.store:integrations-spring-boot3 -->
25-
<org.springframework.boot.version>3.4.0</org.springframework.boot.version>
25+
<org.springframework.boot.version>3.4.1</org.springframework.boot.version>
2626
<org.eclipse.store.version>2.1.0</org.eclipse.store.version>
2727
<org.eclipse.serializer.version>2.1.0</org.eclipse.serializer.version>
2828
<org.eclipse.storage-restservice-springboot.version>2.1.0</org.eclipse.storage-restservice-springboot.version>
@@ -107,7 +107,7 @@
107107
<dependency>
108108
<groupId>com.puppycrawl.tools</groupId>
109109
<artifactId>checkstyle</artifactId>
110-
<version>10.21.0</version>
110+
<version>10.21.1</version>
111111
</dependency>
112112
</dependencies>
113113
<configuration>
@@ -150,12 +150,12 @@
150150
<dependency>
151151
<groupId>net.sourceforge.pmd</groupId>
152152
<artifactId>pmd-core</artifactId>
153-
<version>7.8.0</version>
153+
<version>7.9.0</version>
154154
</dependency>
155155
<dependency>
156156
<groupId>net.sourceforge.pmd</groupId>
157157
<artifactId>pmd-java</artifactId>
158-
<version>7.8.0</version>
158+
<version>7.9.0</version>
159159
</dependency>
160160
</dependencies>
161161
</plugin>

spring-data-eclipse-store-benchmark/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
<parent>
66
<groupId>software.xdev</groupId>
77
<artifactId>spring-data-eclipse-store-root</artifactId>
8-
<version>2.4.2-SNAPSHOT</version>
8+
<version>2.5.0-SNAPSHOT</version>
99
</parent>
1010

1111
<artifactId>spring-data-eclipse-store-benchmark</artifactId>
12-
<version>2.4.2-SNAPSHOT</version>
12+
<version>2.5.0-SNAPSHOT</version>
1313
<packaging>jar</packaging>
1414

1515
<inceptionYear>2023</inceptionYear>

spring-data-eclipse-store-demo/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
<parent>
88
<groupId>software.xdev</groupId>
99
<artifactId>spring-data-eclipse-store-root</artifactId>
10-
<version>2.4.2-SNAPSHOT</version>
10+
<version>2.5.0-SNAPSHOT</version>
1111
</parent>
1212

1313
<artifactId>spring-data-eclipse-store-demo</artifactId>
14-
<version>2.4.2-SNAPSHOT</version>
14+
<version>2.5.0-SNAPSHOT</version>
1515
<packaging>jar</packaging>
1616

1717
<organization>

spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/complex/ComplexDemoApplication.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ public void run(final String... args)
5555
*/
5656
private void ownerCalls()
5757
{
58-
this.ownerService.logOwners();
59-
this.ownerService.deleteAll();
60-
this.ownerService.logOwners();
61-
this.ownerService.createNewOwnerAndVisit();
58+
this.ownerService.createNewOwnerAndVisit("Stevie", "Nicks", "Peter");
6259
this.ownerService.logOwnersAndVisits();
6360
}
6461

spring-data-eclipse-store-demo/src/main/java/software/xdev/spring/data/eclipse/store/demo/complex/OwnerService.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,16 @@ public void logOwnersAndVisits()
8888
/**
8989
* Transactional
9090
*/
91-
public void createNewOwnerAndVisit()
91+
public void createNewOwnerAndVisit(final String ownerFirstName, final String ownerLastName, final String petName)
9292
{
9393
new TransactionTemplate(this.transactionManager).execute(
9494
status ->
9595
{
96-
final Owner owner = this.createOwner();
96+
final Owner owner = this.createOwner(ownerFirstName, ownerLastName, petName);
9797
this.ownerRepository.save(owner);
9898

9999
final Visit visit = this.createVisit();
100-
owner.addVisit("Peter", visit);
100+
owner.addVisit(petName, visit);
101101
this.ownerRepository.save(owner);
102102
LOG.info("----Stored new owner and visit----");
103103
return null;
@@ -113,14 +113,14 @@ private Visit createVisit()
113113
}
114114

115115
@SuppressWarnings("checkstyle:MagicNumber")
116-
private Owner createOwner()
116+
private Owner createOwner(final String ownerFirstName, final String ownerLastName, final String petName)
117117
{
118118
final Owner owner = new Owner();
119-
owner.setFirstName("Stevie");
120-
owner.setLastName("Nicks");
119+
owner.setFirstName(ownerFirstName);
120+
owner.setLastName(ownerLastName);
121121
final Pet pet = new Pet();
122122
pet.setBirthDate(LocalDate.now().minusWeeks(6));
123-
pet.setName("Peter");
123+
pet.setName(petName);
124124
final PetType petType = new PetType();
125125
petType.setName("Dog");
126126
pet.setType(petType);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright © 2024 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.spring.data.eclipse.store.demo.complex.migration;
17+
18+
import org.springframework.beans.factory.annotation.Autowired;
19+
import org.springframework.stereotype.Component;
20+
21+
import software.xdev.micromigration.eclipsestore.MigrationEmbeddedStorageManager;
22+
import software.xdev.micromigration.scripts.Context;
23+
import software.xdev.micromigration.version.MigrationVersion;
24+
import software.xdev.spring.data.eclipse.store.demo.complex.OwnerService;
25+
import software.xdev.spring.data.eclipse.store.repository.root.VersionedRoot;
26+
import software.xdev.spring.data.eclipse.store.repository.root.data.version.DataMigrationScript;
27+
28+
29+
/**
30+
* This is automatically called by the
31+
* {@link software.xdev.spring.data.eclipse.store.repository.root.data.version.DataMigrater} through dependency
32+
* injection.
33+
* <p>
34+
* In contrast to {@link v1_0_0_Init} the version of this script is defined in the method {@link #getTargetVersion()}.
35+
*/
36+
@Component
37+
public class CustomNameScript implements DataMigrationScript
38+
{
39+
private final OwnerService service;
40+
41+
public CustomNameScript(@Autowired final OwnerService service)
42+
{
43+
this.service = service;
44+
}
45+
46+
@Override
47+
public MigrationVersion getTargetVersion()
48+
{
49+
return new MigrationVersion(1, 1, 0);
50+
}
51+
52+
@Override
53+
public void migrate(final Context<VersionedRoot, MigrationEmbeddedStorageManager> context)
54+
{
55+
this.service.createNewOwnerAndVisit("John", "McVie", "Ivan");
56+
}
57+
}

0 commit comments

Comments
 (0)