Skip to content

Commit 99ff619

Browse files
Cleanup
1 parent 5e7bb5d commit 99ff619

File tree

12 files changed

+256
-12
lines changed

12 files changed

+256
-12
lines changed

.run/Run Benchmark.run.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<configuration default="false" name="Run Benchmark" type="Application" factoryName="Application">
33
<option name="MAIN_CLASS_NAME" value="software.xdev.spring.data.eclipse.store.benchmark.BenchmarkRunner" />
44
<module name="spring-data-eclipse-store-benchmark" />
5-
<option name="VM_PARAMETERS" value="-Xmx24g --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED" />
5+
<option name="VM_PARAMETERS" value="--add-opens java.base/java.util=ALL-UNNAMED" />
66
<extension name="coverage">
77
<pattern>
88
<option name="PATTERN" value="software.xdev.spring.data.eclipse.store.benchmark.benchmarks.simple.user.*" />

.run/Run Complex Demo.run.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<configuration default="false" name="Run Complex Demo" type="Application" factoryName="Application">
33
<option name="MAIN_CLASS_NAME" value="software.xdev.spring.data.eclipse.store.demo.complex.ComplexDemoApplication" />
44
<module name="spring-data-eclipse-store-demo" />
5-
<option name="VM_PARAMETERS" value="--add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED" />
5+
<option name="VM_PARAMETERS" value="--add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.time=ALL-UNNAMED" />
66
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
77
<extension name="coverage">
88
<pattern>

.run/Run Simple Demo.run.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<configuration default="false" name="Run Simple Demo" type="Application" factoryName="Application">
33
<option name="MAIN_CLASS_NAME" value="software.xdev.spring.data.eclipse.store.demo.simple.SimpleDemoApplication" />
44
<module name="spring-data-eclipse-store-demo" />
5-
<option name="VM_PARAMETERS" value="--add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED" />
65
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
76
<extension name="coverage">
87
<pattern>

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,17 @@ more [complex demo](./spring-data-eclipse-store-demo/src/main/java/software/xdev
7676
> [!NOTE]
7777
> Since the library is using reflection to copy data, the following JVM-Arguments may have to be set:
7878
> ```
79-
> --add-opens=java.base/java.lang=ALL-UNNAMED
80-
> --add-opens=java.base/java.lang.reflect=ALL-UNNAMED
8179
> --add-opens=java.base/java.util=ALL-UNNAMED
80+
> --add-exports java.base/jdk.internal.misc=ALL-UNNAMED
81+
> --add-opens=java.base/java.lang=ALL-UNNAMED
8282
> --add-opens=java.base/java.time=ALL-UNNAMED
8383
> ```
8484
8585
8686
## Support
87-
If you need support as soon as possible and you can't wait for any pull request, feel free to use [our support](https://xdev.software/en/services/support).
87+
88+
If you need support as soon as possible, and you can't wait for any pull request, feel free to
89+
use [our support](https://xdev.software/en/services/support).
8890
8991
## Contributing
9092
See the [contributing guide](./CONTRIBUTING.md) for detailed instructions on how to get started with our project.

spring-data-eclipse-store/pom.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,7 @@
295295
<configuration>
296296
<argLine>
297297
--add-opens java.base/java.util=ALL-UNNAMED
298-
--add-opens java.base/java.lang=ALL-UNNAMED
299-
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED
300298
--add-exports java.base/jdk.internal.misc=ALL-UNNAMED
301-
-Djdk.reflect.useDirectMethodHandle=false
302299
</argLine>
303300
</configuration>
304301
</plugin>

spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/exceptions/MergeFailedException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public MergeFailedException(final Object sourceObject, final Object targetObject
2121
{
2222
super(
2323
String.format(
24-
"Could not merge values of object %s# with object %s",
24+
"Could not merge values of object %s with object %s",
2525
sourceObject.getClass().getName(),
2626
targetObject.getClass().getName()
2727
),

spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreStorage.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import jakarta.inject.Inject;
2727
import jakarta.inject.Named;
2828

29+
import org.eclipse.serializer.persistence.binary.jdk17.java.util.BinaryHandlerImmutableCollectionsList12;
30+
import org.eclipse.serializer.persistence.binary.jdk17.java.util.BinaryHandlerImmutableCollectionsSet12;
2931
import org.eclipse.serializer.persistence.types.Storer;
3032
import org.eclipse.store.integrations.spring.boot.types.EclipseStoreProvider;
3133
import org.eclipse.store.integrations.spring.boot.types.configuration.EclipseStoreProperties;
@@ -88,6 +90,8 @@ private synchronized void ensureEntitiesInRoot()
8890
this.root = new Root();
8991
final EmbeddedStorageFoundation<?> embeddedStorageFoundation =
9092
this.storeProvider.createStorageFoundation(this.storeConfiguration);
93+
embeddedStorageFoundation.registerTypeHandler(BinaryHandlerImmutableCollectionsSet12.New());
94+
embeddedStorageFoundation.registerTypeHandler(BinaryHandlerImmutableCollectionsList12.New());
9195
this.storageManager = embeddedStorageFoundation.start(this.root);
9296
this.persistenceChecker = new RelayedPersistenceChecker(embeddedStorageFoundation);
9397
this.initRoot();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright © 2023 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.integration.repositories;
17+
18+
import org.springframework.data.repository.CrudRepository;
19+
20+
21+
public interface CustomerRepositoryWithNonFinalHashSet extends CrudRepository<CustomerWithNonFinalHashSet, String>
22+
{
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/*
2+
* Copyright © 2023 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.integration.repositories;
17+
18+
import java.util.HashSet;
19+
import java.util.List;
20+
import java.util.Objects;
21+
import java.util.Set;
22+
23+
24+
public class CustomerWithNonFinalHashSet
25+
{
26+
private String firstName;
27+
private String lastName;
28+
29+
private Set<String> values = new HashSet<>();
30+
31+
public CustomerWithNonFinalHashSet(final String firstName, final String lastName)
32+
{
33+
this.firstName = firstName;
34+
this.lastName = lastName;
35+
}
36+
37+
public void setValues(final Set<String> values)
38+
{
39+
this.values = values;
40+
}
41+
42+
public String getFirstName()
43+
{
44+
return this.firstName;
45+
}
46+
47+
public void setFirstName(final String firstName)
48+
{
49+
this.firstName = firstName;
50+
}
51+
52+
public String getLastName()
53+
{
54+
return this.lastName;
55+
}
56+
57+
public void setLastName(final String lastName)
58+
{
59+
this.lastName = lastName;
60+
}
61+
62+
public Set<String> getValues()
63+
{
64+
return this.values;
65+
}
66+
67+
@Override
68+
public String toString()
69+
{
70+
return String.format(
71+
"Customer[firstName='%s', lastName='%s']",
72+
this.firstName, this.lastName);
73+
}
74+
75+
@Override
76+
public boolean equals(final Object o)
77+
{
78+
if(this == o)
79+
{
80+
return true;
81+
}
82+
if(o == null || this.getClass() != o.getClass())
83+
{
84+
return false;
85+
}
86+
final CustomerWithNonFinalHashSet customer = (CustomerWithNonFinalHashSet)o;
87+
return Objects.equals(this.firstName, customer.firstName) && Objects.equals(
88+
this.lastName,
89+
customer.lastName);
90+
}
91+
92+
@Override
93+
public int hashCode()
94+
{
95+
return Objects.hash(this.firstName, this.lastName);
96+
}
97+
98+
@SuppressWarnings("OptionalGetWithoutIsPresent")
99+
public static CustomerWithNonFinalHashSet getCustomerWithFirstName(
100+
final List<CustomerWithNonFinalHashSet> customers,
101+
final String firstName)
102+
{
103+
return customers.stream().filter(customer -> customer.getFirstName().equals(firstName)).findFirst().get();
104+
}
105+
}

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/repositories/Node.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class Node
2424
{
2525
private String name;
2626

27-
private final List<Node> children;
27+
private List<Node> children;
2828

2929
public Node(final String name, final List<Node> children)
3030
{
@@ -47,6 +47,11 @@ public void setName(final String name)
4747
this.name = name;
4848
}
4949

50+
public void setChildren(final List<Node> children)
51+
{
52+
this.children = children;
53+
}
54+
5055
public List<Node> getChildren()
5156
{
5257
return this.children;

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/tests/HashSetTest.java

Lines changed: 110 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,21 @@
1616
package software.xdev.spring.data.eclipse.store.integration.tests;
1717

1818
import java.util.List;
19+
import java.util.Set;
20+
21+
import jakarta.inject.Inject;
1922

2023
import org.junit.jupiter.api.Assertions;
2124
import org.junit.jupiter.api.Disabled;
2225
import org.junit.jupiter.api.Test;
2326

24-
import jakarta.inject.Inject;
2527
import software.xdev.spring.data.eclipse.store.helper.TestData;
2628
import software.xdev.spring.data.eclipse.store.helper.TestUtil;
2729
import software.xdev.spring.data.eclipse.store.integration.DefaultTestAnnotations;
2830
import software.xdev.spring.data.eclipse.store.integration.repositories.CustomerRepositoryWithHashSet;
31+
import software.xdev.spring.data.eclipse.store.integration.repositories.CustomerRepositoryWithNonFinalHashSet;
2932
import software.xdev.spring.data.eclipse.store.integration.repositories.CustomerWithHashSet;
33+
import software.xdev.spring.data.eclipse.store.integration.repositories.CustomerWithNonFinalHashSet;
3034
import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage;
3135

3236

@@ -35,6 +39,8 @@ class HashSetTest
3539
{
3640
@Inject
3741
private CustomerRepositoryWithHashSet repository;
42+
@Inject
43+
private CustomerRepositoryWithNonFinalHashSet nonFinalRepository;
3844

3945
@Inject
4046
private EclipseStoreStorage storage;
@@ -56,6 +62,109 @@ void testSaveAndFindAll()
5662
);
5763
}
5864

65+
@Test
66+
void testSaveAndResaveFindAll()
67+
{
68+
final CustomerWithHashSet customer = new CustomerWithHashSet(TestData.FIRST_NAME, TestData.LAST_NAME);
69+
customer.getValues().add("Test");
70+
this.repository.save(customer);
71+
72+
final CustomerWithHashSet customerWithHashSet =
73+
TestUtil.iterableToList(this.repository.findAll()).stream().findFirst().get();
74+
customerWithHashSet.getValues().add("Test2");
75+
this.repository.save(customerWithHashSet);
76+
77+
TestUtil.doBeforeAndAfterRestartOfDatastore(
78+
this.storage,
79+
() -> {
80+
final List<CustomerWithHashSet> customers = TestUtil.iterableToList(this.repository.findAll());
81+
Assertions.assertEquals(1, customers.size());
82+
Assertions.assertEquals(2, customers.get(0).getValues().size());
83+
}
84+
);
85+
}
86+
87+
@Test
88+
void testSaveAndFindAllNonFinal()
89+
{
90+
final CustomerWithNonFinalHashSet customer =
91+
new CustomerWithNonFinalHashSet(TestData.FIRST_NAME, TestData.LAST_NAME);
92+
customer.getValues().add("Test");
93+
this.nonFinalRepository.save(customer);
94+
95+
TestUtil.doBeforeAndAfterRestartOfDatastore(
96+
this.storage,
97+
() -> {
98+
final List<CustomerWithNonFinalHashSet> customers =
99+
TestUtil.iterableToList(this.nonFinalRepository.findAll());
100+
Assertions.assertEquals(1, customers.size());
101+
Assertions.assertEquals(1, customers.get(0).getValues().size());
102+
}
103+
);
104+
}
105+
106+
@Test
107+
void testSaveAndSetAndFindAllNonFinal()
108+
{
109+
final CustomerWithNonFinalHashSet customer =
110+
new CustomerWithNonFinalHashSet(TestData.FIRST_NAME, TestData.LAST_NAME);
111+
customer.setValues(Set.of("Test"));
112+
this.nonFinalRepository.save(customer);
113+
114+
TestUtil.doBeforeAndAfterRestartOfDatastore(
115+
this.storage,
116+
() -> {
117+
final List<CustomerWithNonFinalHashSet> customers =
118+
TestUtil.iterableToList(this.nonFinalRepository.findAll());
119+
Assertions.assertEquals(1, customers.size());
120+
Assertions.assertEquals(1, customers.get(0).getValues().size());
121+
}
122+
);
123+
}
124+
125+
@Test
126+
void testSaveAndResetAndFindAllNonFinal()
127+
{
128+
final CustomerWithNonFinalHashSet customer =
129+
new CustomerWithNonFinalHashSet(TestData.FIRST_NAME, TestData.LAST_NAME);
130+
customer.setValues(Set.of("Test"));
131+
this.nonFinalRepository.save(customer);
132+
133+
final CustomerWithNonFinalHashSet customerWithHashSet =
134+
TestUtil.iterableToList(this.nonFinalRepository.findAll()).stream().findFirst().get();
135+
customerWithHashSet.setValues(Set.of("Test", "Test2"));
136+
this.nonFinalRepository.save(customerWithHashSet);
137+
138+
TestUtil.doBeforeAndAfterRestartOfDatastore(
139+
this.storage,
140+
() -> {
141+
final List<CustomerWithNonFinalHashSet> customers =
142+
TestUtil.iterableToList(this.nonFinalRepository.findAll());
143+
Assertions.assertEquals(1, customers.size());
144+
Assertions.assertEquals(2, customers.get(0).getValues().size());
145+
}
146+
);
147+
}
148+
149+
@Test
150+
void testSaveAndSetNullAndFindAllNonFinal()
151+
{
152+
final CustomerWithNonFinalHashSet customer =
153+
new CustomerWithNonFinalHashSet(TestData.FIRST_NAME, TestData.LAST_NAME);
154+
customer.setValues(null);
155+
this.nonFinalRepository.save(customer);
156+
157+
TestUtil.doBeforeAndAfterRestartOfDatastore(
158+
this.storage,
159+
() -> {
160+
final List<CustomerWithNonFinalHashSet> customers =
161+
TestUtil.iterableToList(this.nonFinalRepository.findAll());
162+
Assertions.assertEquals(1, customers.size());
163+
Assertions.assertNull(customers.get(0).getValues());
164+
}
165+
);
166+
}
167+
59168
// TODO: Fix this.
60169
@Test
61170
@Disabled("Is not fixed yet, but will be.")

0 commit comments

Comments
 (0)