Hi all,
I am using Spring Data Neo4J 6.1.2 and would like to retrieve node entities by a relationship property. I am currently using dynamic relationships.
On the node entity I have this:
@Node("Entity")
@Data
public class Entity {
@Id
@GeneratedValue(UUIDStringGenerator.class)
private String id;
...
@Relationship
private Map<String, List<RelatedEntity>> relatedEntities = new HashMap<>();
On the relationship I have the following properties:
@RelationshipProperties
@Data
public class RelatedEntity {
@Id
@GeneratedValue()
private Long id;
@TargetNode
private Entity relEntity;
...
private String createdBy;
I want to create repository methods to retrieve entities by the id and created by field. I have tried these:
List<Entity> findByRelatedEntitiesCreatedBy(String createdBy);
List<Entity> findByRelatedEntitiesId(Long id);
But I get this exception:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityNeo4jRepository' defined in company.graph.repository.EntityNeo4jRepository defined in @EnableNeo4jRepositories declared on Neo4jRepositoriesRegistrar.EnableNeo4jRepositoriesConfiguration: Invocation of init method failed; nested exception is org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract java.util.List company.graph.repository.EntityNeo4jRepository.findByRelatedEntitiesCreatedBy(java.lang.String)! Reason: No property createdBy found for type List! Traversed path: Entity.relatedEntities.; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property createdBy found for type List! Traversed path: Entity.relatedEntities.
What am I doing wrong?