ms007
(Marc Seiferle)
January 7, 2022, 2:18pm
1
Hi there,
We are having a hard time upgrading from sdn 5.3.x to 6.2.
Our entities are inherited from a base domain object:
@SuperBuilder
@NoArgsConstructor
public abstract class BaseDomainObject {
@Id
@GeneratedValue(strategy = StringUuidStrategy.class)
@Getter
public String id;
@Id
@GeneratedValue
@Getter
private Long internalId;
}
And the entities do not contain an @Id itself.
@Node
@NoArgsConstructor
@SuperBuilder
public class Competence extends BaseDomainObject {
@Getter
@Setter
@Property
String name;
}
in sdn 5.3 this works just fine but sdn 6.2 throws with the following error message
Missing id property on class xxxxxx
Saw this PR where the check was added:
neo4j:master
← neo4j:issue/gh-224
opened 10:22AM - 28 Apr 20 UTC
If a class is annotated with `@Node` we can assume that it is the intention of t… he user to map this entity later. This will mark the entity as an explicit entity and we could apply stricter verification if needed.
This PR uses this mechanism for throwing an exception if the id property is missing.
closes #224
What's the proposed migration path for this issue?
Thank you in advice
ms007
(Marc Seiferle)
January 7, 2022, 3:19pm
2
Never mind. Had the wrong imports
import org.neo4j.ogm.annotation.GeneratedValue;
import org.neo4j.ogm.annotation.Id;
instead of
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;
One question remains.
We need to get the internal id as well. How can we obtain that in the base class?
You can only have one identifying property in an entity (or its parent classes/interfaces).
Either treat the UUID as just another property or fetch the internal id manually with the Neo4jClient
and e.g. a Cypher statement with the UUID in the condition part, if the internal id is not needed all the time.