'Neo4j relation is not creating with Spring Data

I am using neo4j database and Springboot with Kotlin and having an issue creating a relationship that contains data. Here is the code:

Entity that uses relationship

package com.skillprojects.app.model.enitity

import com.skillprojects.app.model.relation.UserToProjectsRelation
import org.springframework.data.neo4j.core.schema.*

@Node("Projects")
class ProjectEntity(
    @Id
    val projectName: String = "",
    @Relationship(type = "OWNED_BY", direction =  Relationship.Direction.OUTGOING)
    val client: ClientEntity,
    @Relationship(type = "PART_OF", direction = Relationship.Direction.OUTGOING)
    val industry: IndustryEntity,
    val projectDescription: String,// todo: limit to 2000 chars in service
    // after this use data on relation
    @Relationship(type = "UserToProjectsRelation", direction = Relationship.Direction.INCOMING)
    var user: UserToProjectsRelation
//    var activeDates: List<DateEntity>,
//    val role: RoleEntity,
//    var skills: List<SkillEntity>,
//    var responsibilities: List<String> // todo: limit to 200 chars in service
) {
}

The relation itself

package com.skillprojects.app.model.relation

import com.skillprojects.app.model.enitity.DateEntity
import com.skillprojects.app.model.enitity.RoleEntity
import com.skillprojects.app.model.enitity.SkillEntity
import com.skillprojects.app.model.enitity.UserEntity
import com.skillprojects.app.repository.UserRepository
import org.springframework.data.neo4j.core.schema.*

@RelationshipProperties
class UserToProjectsRelation(
    @RelationshipId
    var id: Long,
    var activeDates: List<DateEntity>,
    val role: RoleEntity,
    var skills: List<SkillEntity>,
    val responsibilities: List<String>,

    @TargetNode
    var user:UserEntity
) {

}

And a sample Entity that is stored in relation list

package com.skillprojects.app.model.enitity

import org.springframework.data.neo4j.core.schema.GeneratedValue
import org.springframework.data.neo4j.core.schema.Id
import org.springframework.data.neo4j.core.schema.Node

@Node("ActiveDates")
class DateEntity(
    @Id
    @GeneratedValue
    val id: Long,
    val startDate: Long, // stores epoch timestamp
    val endDate: Long?
) {

}

The data after inserting project entity with all the data needed through a post request:

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source