Skip to content

Neo4jRepository.SaveAll() Does not work for entities with @CompositeProperty #2493

Closed

Description

@jposthauer

When I try to use saveAll() to save a list of entities where the entity class has a @CompositeProperty it is throwing the following error:

Unable to convert org.springframework.data.neo4j.core.mapping.MapValueWrapper to Neo4j Value.; Error code 'N/A';

The error happens in the org.neo4j.driver.Values class in the Value value( Object value ) method.

This error occurred when we went from 6.2.1 -> 6.2.2.
Neo4j java driver: 4.4.3

Replicate using the following:

@Node
@Getter
@Setter
public class TestObject {

  @Id
  @Property(name = "id")
  @GeneratedValue(value = UUIDStringGenerator.class)
  protected String id;

  @JsonIgnore
  @CompositeProperty(delimiter = "", converter = TestConverter.class)
  private TestData data;

  public TestObject(TestData aData) {
    super();
    data = aData;
  }

}
public class TestConverter implements Neo4jPersistentPropertyToMapConverter<String, TestData> {

  static final String NUM = "Num";
  static final String STRING = "String";

  @NotNull
  @Override
  public Map<String, Value> decompose(@Nullable TestData property,
                                      @NotNull Neo4jConversionService neo4jConversionService) {
    return property == null
        ? Map.of()
        : Map.of(NUM, Values.value(property.getNum()), STRING, Values.value(property.getString()));
  }

  @NotNull
  @Override
  public TestData compose(Map<String, Value> source,
                          @NotNull Neo4jConversionService neo4jConversionService) {
    TestData data = new TestData();
    if (source.get(NUM) != null) {
      data.setNum(source.get(NUM).asInt());
    }
    if (source.get(STRING) != null) {
      data.setString(source.get(STRING).asString());
    }
    return data;
  }
}
@Getter
@Setter
public class TestData {

  private int num;
  private String string;

  public TestData() {
    super();
  }

  public TestData(int num, String string) {
    this.num = num;
    this.string = string;
  }

}
public interface TestObjectRepository extends Neo4jRepository<TestObject, String> {

}

Error will be thrown when calling TestObjectRepository.saveAll() for a list of TestObjects.

Activity

  1. jposthauer commented on Mar 29, 2022

    @jposthauer
    Author

    This issue persists in spring-data-neo4j:6.2.3 as well.

  2. michael-simons commented on Mar 29, 2022

    @michael-simons
    Collaborator

    Thanks for the ping. No wonder that it still persists, it is still open… Sorry for the oversight here.

  3. michael-simons commented on Mar 31, 2022

    @michael-simons
    Collaborator

    Caused by the fix for #2451

  4. michael-simons commented on Mar 31, 2022

    @michael-simons
    Collaborator

    Excellent reproducer, @jposthauer A fix is on the way.

  5. added 3 commits that reference this issue on Mar 31, 2022
  6. added a commit that references this issue on Aug 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions