cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

SDN 6.2 Abstract Base Class / @Id Property

ms007
Node Link

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:

What's the proposed migration path for this issue?
Thank you in advice

2 REPLIES 2

ms007
Node Link

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.