SDN6 - 投影接口与 属性 映射

SDN6 - Projection interfaces with Property Mapping

我正在使用 spring data neo4j 6.1.3,以下是我的用例代码片段

域实体

    @Data
    @Node("DATspace")
    public class DatSpace {

      @Id @GeneratedValue
      private Long neoId;

      @Property("SUPtitle")
      private String title;

      private String SUPid;
    }

测试class

@SpringBootTest
@EnableNeo4jRepositories(basePackages = "com.rahal.marvel")
public class ProjectionTest {

   @Autowired
   private Neo4jTemplate neo4jTemplate;

   interface DATspaceProjection {
      String getTitle();
      String getSUPid();
   }

   @Test
   public void test_projection(){
      DatSpace d = neo4jTemplate.findOne("MATCH (s:DATspace {SUPid: $id}) RETURN s", Collections.singletonMap("id", "SPC_ML7"), DatSpace.class).get();

      d.setTitle("title modified");
      d.setSUPid("SUPid modified");

      DATspaceProjection   p = neo4jTemplate.saveAs(d, DATspaceProjection.class);
   }
}

理想情况下,上面的 saveAs 函数应该同时修改 DATspace.SUPtitle 和 DATspace.SUPid。但是它只修改 SUPid 而不是 SUPtitle。我认为这是由于 属性 映射 (@属性) 造成的。这是一个错误还是有任何解决方法?

所提供的 @Property 注释只会对注释的 属性 (title) 本身产生影响。 目前没有从投影中的 getTitle() 方法到域 class.

中带注释的 title 字段的知识

为了安全起见,修改时请使用明确的 属性 名称:

interface DATspaceProjection {
    String getSUPtitle();
    String getSUPid();
}

我创建了一个改进问题 https://github.com/spring-projects/spring-data-neo4j/issues/2371