So far Spring-Data-Neo4J works great but now i am hitting a problem:
In one of my "Neo4jRepository" for ProductResponsibleUnitRelation
i declare a method:
List<ProductResponsibleUnitRelation> findByProductHierarchyIdContainingIgnoreCase(String partialProductHierarchyId);
Using this method yields this exception:
Caused by: java.lang.IllegalStateException: Unable to ignore case of java.lang.String types, the property 'productHierarchy' must reference a String
at org.springframework.util.Assert.state(Assert.java:73)
at org.springframework.data.neo4j.repository.query.filter.PropertyComparisonBuilder.applyCaseInsensitivityIfShouldIgnoreCase(PropertyComparisonBuilder.java:101)
at org.springframework.data.neo4j.repository.query.filter.PropertyComparisonBuilder.build(PropertyComparisonBuilder.java:49)
Inspecting code of org.springframework.data.neo4j.repository.query.filter.PropertyComparisonBuilder reveals the problem. The method canIgnoreCase
is called it looks like this:
private boolean canIgnoreCase(Part part) {
return part.getType() == SIMPLE_PROPERTY && String.class.equals(part.getProperty().getLeafType());
}
It seems that the use of IgnoreCase (part.getType()
) is only allowed for SIMPLE_PROPERTY
but no for all others like CONTAINING
.
The question is: How could i get a working findByContainingIgnoreCase method, preferable without using cypher (i am using spring data to abstract from these details).
My OGM calsses are these:
@RelationshipEntity(type = "responsible_for_product")
@Data
public class ProductResponsibleUnitRelation {
@Id
@GeneratedValue
private Long id;
@StartNode
private LegalEntityNode legalEntity;
@EndNode
private ProductHierarchyNode productHierarchy;
private LocalDate validFrom;
private LocalDate validTo;
}
@NodeEntity
@Data
public class ProductHierarchyNode {
@Id
private String id;
}
I want to find all relations by case insensitive parts ("containing") of the id.