I have the following Spring Data Neo4j 5 entity:
@NodeEntity
public class Value extends Flaggable {
@Index(unique = true)
private Long id;
private String name;
private String description;
@Index(unique = false)
private Object value;
}
Right now the Value
nodes have the following labels:
MATCH(n:Value) RETURN labels(n) LIMITS 1
["BaseEntity", "Subscribable", "Flaggable", "Likeable", "Value"]
In some cases, according to my project requirements I need to extend the Value
node with additional properties, like for example weight
and size
.
I don't want to change the existing Value
class and want to introduce a new - inherited one, for example:
@NodeEntity
public class WeightedValue extends Value{
private Long weight;
private Long size;
}
I have a question, will the following query MATCH(n:Value) RETURN n
return also the instances of WeightedValue
?
Will it be possible to search WeightedValue
nodes(by Value
label) by the following query?
MATCH(n:Value) WHERE n.size > 1000 RETURN n
Will the approach above work for @RelationshipEntity
and inheritance? So is it possible to use inheritance for @RelationshipEntity
and how to keep the same label(for example HAS_VALUE_ON
) for the base and inherited classes, for example:
@RelationshipEntity(type = "HAS_VALUE_ON")
public class RelationshipValue {
@Id
@GeneratedValue
private Long id;
@StartNode
private Decision decision;
@EndNode
private Characteristic characteristic;
}
@RelationshipEntity(type = "HAS_VALUE_ON")
public class WeightedRelationshipValue extends RelationshipValue {
private Long weight;
private Long size;
}