Skip to content

Custom generated ID for relationships not supported? #2497

Closed
@nioertel

Description

@nioertel

We're currently upgrading our application from Spring Boot 2.3.9 to 2.6.4 which means upgrade from SDN 5.3.7 + OGM 3.2.20 to SDN 6.2.2.

In our graph model relationships are a first class citizen with rich relationship entities throughout the graph. Some relationships also need to be uniquely identified outside of our system so we give them a custom generated UUID on creation and basically treat them the same way as nodes on the metadata level (createdOn/By, modifiedOn/By, versioning).

SDN 6.2.2 throws the following exception with this setup:

java.lang.IllegalStateException: The class `com.example.MyRel` 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.

This error is expected as the documentation states:

You must define a property for the generated, internal ID (@RelationshipId) so that SDN can determine
during save which relationships can be safely overwritten without losing properties. If SDN does not
find a field for storing the internal node id, it will fail during startup.

I was wondering if this restriction was introduced on purpose and if there are any thoughts on loosening it so we can provide a custom generatorClass also for relationships.
Our domain model is quite big and relationships as well as nodes are inheriting from the same base class that implements everything around auditing, locking and ID generation. I would like to avoid this refactoring if possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions