Skip to content

Commit 29737c3

Browse files
committed
Enhance warning message for missing entity ids.
1 parent 415ef6d commit 29737c3

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/main/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jPersistentEntity.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ private void verifyAssociationsWithProperties() {
265265
if (this.isRelationshipPropertiesEntity()) {
266266
Supplier<String> messageSupplier = () -> String.format(
267267
"The class `%s` for the properties of a relationship "
268-
+ "is missing a property for the generated, internal ID (`@Id @GeneratedValue Long id`) "
268+
+ "is missing a property for the generated, internal ID (`@Id @GeneratedValue Long id` "
269+
+ "or `@Id @GeneratedValue String id`) "
269270
+ "which is needed for safely updating properties",
270271
this.getUnderlyingClass().getName());
271272
Assert.state(this.getIdDescription() != null && this.getIdDescription().isInternallyGeneratedId(), messageSupplier);

src/test/java/org/springframework/data/neo4j/core/mapping/Neo4jMappingContextTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void startupWithoutInternallyGeneratedIDShouldFail() {
9595
Arrays.asList(IrrelevantSourceContainer.class, InvalidRelationshipPropertyContainer.class,
9696
IrrelevantTargetContainer.class)));
9797
schema.initialize();
98-
}).withMessage("The class `org.springframework.data.neo4j.core.mapping.Neo4jMappingContextTest$InvalidRelationshipPropertyContainer` for the properties of a relationship is missing a property for the generated, internal ID (`@Id @GeneratedValue Long id`) which is needed for safely updating properties");
98+
}).withMessage("The class `org.springframework.data.neo4j.core.mapping.Neo4jMappingContextTest$InvalidRelationshipPropertyContainer` for the properties of a relationship is missing a property for the generated, internal ID (`@Id @GeneratedValue Long id` or `@Id @GeneratedValue String id`) which is needed for safely updating properties");
9999
}
100100

101101
@Test // GH-2214
@@ -107,7 +107,7 @@ void startupWithWrongKindOfGeneratedIDShouldFail() {
107107
Arrays.asList(IrrelevantSourceContainer3.class, InvalidRelationshipPropertyContainer2.class,
108108
IrrelevantTargetContainer.class)));
109109
schema.initialize();
110-
}).withMessage("The class `org.springframework.data.neo4j.core.mapping.Neo4jMappingContextTest$InvalidRelationshipPropertyContainer2` for the properties of a relationship is missing a property for the generated, internal ID (`@Id @GeneratedValue Long id`) which is needed for safely updating properties");
110+
}).withMessage("The class `org.springframework.data.neo4j.core.mapping.Neo4jMappingContextTest$InvalidRelationshipPropertyContainer2` for the properties of a relationship is missing a property for the generated, internal ID (`@Id @GeneratedValue Long id` or `@Id @GeneratedValue String id`) which is needed for safely updating properties");
111111
}
112112

113113
@Test // GH-2118

0 commit comments

Comments
 (0)