Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jposthauer opened this issue Mar 3, 2022 · 4 comments
Assignees
Labels
type: bug A general bug

Comments

@jposthauer
Copy link

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 3, 2022
@jposthauer
Copy link
Author

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

@michael-simons michael-simons self-assigned this Mar 29, 2022
@michael-simons
Copy link
Collaborator

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

@michael-simons
Copy link
Collaborator

Caused by the fix for #2451

@michael-simons michael-simons added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 31, 2022
@michael-simons michael-simons added this to the 6.1.11 (2021.0.11) milestone Mar 31, 2022
@michael-simons
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants