Enhance warning message for missing entity ids.

This commit is contained in:
Gerrit Meier
2024-01-22 16:36:40 +01:00
parent 1939a1c82e
commit 4e6818b61d
2 changed files with 4 additions and 3 deletions

View File

@@ -265,7 +265,8 @@ final class DefaultNeo4jPersistentEntity<T> extends BasicPersistentEntity<T, Neo
if (this.isRelationshipPropertiesEntity()) {
Supplier<String> messageSupplier = () -> String.format(
"The class `%s` for the properties of a relationship "
+ "is missing a property for the generated, internal ID (`@Id @GeneratedValue Long id`) "
+ "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",
this.getUnderlyingClass().getName());
Assert.state(this.getIdDescription() != null && this.getIdDescription().isInternallyGeneratedId(), messageSupplier);

View File

@@ -95,7 +95,7 @@ class Neo4jMappingContextTest {
Arrays.asList(IrrelevantSourceContainer.class, InvalidRelationshipPropertyContainer.class,
IrrelevantTargetContainer.class)));
schema.initialize();
}).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");
}).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");
}
@Test // GH-2214
@@ -107,7 +107,7 @@ class Neo4jMappingContextTest {
Arrays.asList(IrrelevantSourceContainer3.class, InvalidRelationshipPropertyContainer2.class,
IrrelevantTargetContainer.class)));
schema.initialize();
}).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");
}).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");
}
@Test // GH-2118