Skip to content

Persistence of projections with composite properties #2451

@gonzalad

Description

@gonzalad

Hello,

I'm trying to use persistence of projections on an entity defining a composite property, but the property is not saved.

I'm using SDN 6.2.0.

Here is my testcase:

@Node("Widget")
public class WidgetEntity {

    @GeneratedValue
    @Id
    private Long id;
    private String code;
    private String label;

    @CompositeProperty
    private Map<String, Object> additionalFields = new HashMap<>();

...
}
public interface WidgetProjection {

    String getCode();

    String getLabel();

    Map<String, Object> getAdditionalFields();
}

Unit test:

    @Test
    void testSaveAsWidgetProjectionWithCompositeProperty() {

        String code = "Window1";
        WidgetEntity window = repository.findByCode(code).orElseThrow();
        window.setLabel("changed");
        window.getAdditionalFields().put("key1", "value1");

        template.saveAs(window, WidgetProjection.class);

        window = repository.findByCode(code).orElseThrow();
        assertThat(window.getAdditionalFields()).hasSize(1); => this returns 0 !!
    }

The code is available in this repository: https://github.com/gonzalad/sdn6-tests/blob/projection-persist-composite-properties/src/test/java/com/example/sdn6/Sdn6Test.java (it relies on testcontainers: no special setup for neo4j db required)

Thanks,

N.B. the issue seems to be related to TemplateSupport.createAndApplyPropertyFilter which gets additionalFields.key1 in the NAME_OF_PROPERTIES_PARAM parameter and tries to compare it with the composite property additionalFields

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions