Properties of relationship entities return null in custom @Query

Hello,

I'm trying to model a dependency graph with these nodes. But i have problems to get a result in relationship nodes while querying custom @Query's.

Artefact:

  • Artefact (Label)
  • name: String

Version

  • Version (Label)
  • version: String
  • relationship to Artefact
@NodeEntity
public class Artefact {

    // Properties
    @Id
    @GeneratedValue
    private Long id;

    private String name;

    public Artefact() {}

    public Artefact(String name) {
        this.name = name;
    }

// + getter and setter
@NodeEntity
public class Version {

    // Properties
    @Id
    @GeneratedValue
    private Long id;

    private String version;

    @Relationship(type = "IS_VERSION")
    Artefact artefactsOf;

    public Version() {
    }

    public Version(String version) {
        this.version = version;
    }

// + getter and setter

The findAll() returns all properties of version and of artefactsOf included the names (Property of artefact).

public interface VersionRepository extends Neo4jRepository<Version, Long> {
    
    Iterable<Version> findAll();

but if i use a custom @Query, the artefactsOf return null.
Even with a very easy query, that actually should return the same as findAll.

    @Query("MATCH (v:Version) RETURN v")
    Iterable<Version> getAllVersions();

My results look like this:

*findAll()*

Image2

*getAllVersions()*

Image

What am i implementing wrong that every custom query only returns the properties of version, not the properties of artefact aswell?

I am implementing a large dependency graph of artefacts and version depending on each other. I should also use bigger queries to find nodes in a dependncy graph path. But even my small queries seems not to work.

I hope anyone can help me.

FYI - i am using these dependencies and Neo4j Server version: [4.1.1]

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-neo4j</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-rest</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
			<exclusions>
				<exclusion>
					<groupId>org.junit.vintage</groupId>
					<artifactId>junit-vintage-engine</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

I had a similar issue that was resolved by collecting each of the related nodes in the return.
For example your query would be something like:

MATCH (v:Version) 
OPTIONAL MATCH (v)-[is_version:IS_VERSION]->(artefact:Artefact)
RETURN v, collect(is_version), collect(artefact)

See this example on the sdn-rx github: https://github.com/neo4j/sdn-rx/blob/master/examples/imperative-web/src/main/java/org/neo4j/springframework/data/examples/spring_boot/domain/PersonRepository.java