I am trying to find a way to implement a projection for mapped properties. Following is my code snippets.
Domain Entity
@Data
@Node("DATspace")
public class DatSpace {
@Id @GeneratedValue
private Long neoId;
@Property("SUPtitle")
private String title;
private String SUPid;
}
Test Case
@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);
}
}
Ideally above saveAs function should modify both DATspace.SUPtitle and DATspace.SUPid. However it only modify SUPid but not SUPtitle. I presume it is due to property mapping (@Property) . Is this a bug or are there any workaround?