Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org.springframework.data.mapping.MappingException while trying to use multiple implementations #2761

Open
Kanish2002 opened this issue Jul 7, 2023 · 10 comments
Assignees
Labels
status: feedback-provided Feedback has been provided

Comments

@Kanish2002
Copy link

Kanish2002 commented Jul 7, 2023

Hi I can able to create nodes and rels for multiple implementations..

@Node
class Starter(
    @Id
    val id: Long,
    val name: String,
    @Relationship(type = "RETRIEVES", direction = Relationship.Direction.OUTGOING)
    var dataRetriever: List<DataRetriever>
)

@Node("DataRetriever")
interface DataRetriever


@Node
class WebDataRetriever : DataRetriever{
   @Id
    val id: Long,
    val webDataRetrieverName: String,
    val webDataSource: String,
    val webSource: String,
 @Relationship(type= "Process",direction = Relationship.Direction.OUTGOING)
var dataProcessor: WebDataProcessor
}

@Node("DataProcessor")
interface DataProcessor

@Node
class WebDataProcessor(
    @Id
//some impl
) : DataProcessor

I can able to store that in the neo4j db..

But when trying to retrieve it using Repository..

@Repository
interface StarterRepository : Neo4jRepository<Starter,Long>{
    fun findByName(name: String):Starter
}

I'm getting a exception like
[ restartedMain] .n.c.Neo4jPersistenceExceptionTranslator : Don't know how to translate exception of type class org.springframework.data.mapping.MappingException

Caused by: org.springframework.data.mapping.model.MappingInstantiationException: Failed to instantiate com.zen.neo.NeoTestKotlinNew.model.WebDataRetriever using constructor fun (kotlin.Long, kotlin.String, kotlin.String, kotlin.String, com.zen.neo.NeoTestKotlinNew.model.WebDataProcessor): com.zen.neo.NeoTestKotlinNew.model.WebDataRetriever with arguments 1,webDataRetriever,getWebData,getSrc,null

It's is not mapping to the model correctly! can someone help me to solve this issue!!

SDN version - 6.3.12(from Spring Data Neo4j Starter)
Thanks

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 7, 2023
@meistermeier meistermeier self-assigned this Jul 11, 2023
@meistermeier
Copy link
Collaborator

Isn't Kotlin more strict about null in non-null types? I can see that SDN errors with the parameters 1,webDataRetriever,getWebData,getSrc,null, so it doesn't have any information about the WebDataProcessor.

If this should be not null, the loading of the (Web)DataRetriever (repository and function) would be helpful to get more information.

@meistermeier meistermeier added status: waiting-for-feedback We need additional information before we can continue and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 11, 2023
@Kanish2002
Copy link
Author

Kanish2002 commented Jul 11, 2023

Yeah I'm sharing all my models, repo and graph(and it's building code),

Models

package com.strategies.test1.strategy.githubissues

import org.springframework.data.annotation.PersistenceCreator
import org.springframework.data.neo4j.core.schema.GeneratedValue
import org.springframework.data.neo4j.core.schema.Id
import org.springframework.data.neo4j.core.schema.Node
import org.springframework.data.neo4j.core.schema.Relationship

@Node("Starter")
data class Starter(
    @Id @GeneratedValue
    var id: Long?,
    val name: String,
    @Relationship(type = "RETRIEVES", direction = Relationship.Direction.OUTGOING)
    var dataRetriever: Set<DRetriever>
){
    @PersistenceCreator
    constructor(name: String, dataRetriever: Set<DRetriever>) : this(null,name,dataRetriever)
}
package com.strategies.test1.strategy.githubissues

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

@Node("DataRetriever")
interface DRetriever`

package com.strategies.test1.strategy.githubissues

import org.springframework.data.annotation.PersistenceCreator
import org.springframework.data.neo4j.core.schema.GeneratedValue
import org.springframework.data.neo4j.core.schema.Id
import org.springframework.data.neo4j.core.schema.Node
import org.springframework.data.neo4j.core.schema.Relationship

@Node("WebDataRetriever")
class WebDRetriever(
    @Id
    @GeneratedValue
    var id: Long?,
    val name: String,
    val src1: String,
    val src2: String,
    @Relationship(type = "DATA_PROCESSED_BY", direction = Relationship.Direction.OUTGOING)
    val dataProcessor: DProcessor
): DRetriever {
    @PersistenceCreator
    constructor(name: String, src1: String, src2: String, dataProcessor: DProcessor) : this(null, name, src1, src2, dataProcessor)
}

package com.strategies.test1.strategy.githubissues

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

@Node("DataProcessor")
interface DProcessor


package com.strategies.test1.strategy.githubissues

import org.springframework.data.annotation.PersistenceCreator
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("WebDataProcessor")
class WebDProcessor(
    @Id
    @GeneratedValue
    var id: Long?,
    val src1: String,
    val src2: String
) : DProcessor {
    @PersistenceCreator
    constructor(src1: String,src2: String) : this(null, src1, src2)
}

Repository

package com.strategies.test1.strategy.githubissues

import org.springframework.data.neo4j.repository.Neo4jRepository

interface StarterRepo : Neo4jRepository<Starter,Long>{
    fun findByName(name: String) : Starter
}

Builder

package com.strategies.test1.strategy.githubissues

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.data.neo4j.core.Neo4jTemplate
import org.springframework.stereotype.Component
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController

@RestController
class BuildDemo {
    @Autowired
    lateinit var neo4jTemplate: Neo4jTemplate

    @Autowired
    lateinit var starterRepo: StarterRepo

    @GetMapping("buildit")
    fun build(): String {
        val dProcessor = WebDProcessor("getSrc1","getSrc2")
        val dRetriever = WebDRetriever("webdr","getSrc1","getSrc2",dProcessor)
        val starter = Starter("St", setOf(dRetriever))

        neo4jTemplate.saveAll(
            listOf(
                starter,dRetriever,dProcessor
            )
        )
        return "succeeded"
    }

    @GetMapping("getit")
    fun getit(): Starter {
        return starterRepo.findByName("St")
    }


}

After calling the Endpoint "localhost:8080\buildit"

2023-07-11T12:57:47.138+05:30  INFO 93660 --- [           main] c.s.t.strategy.StrategyApplicationKt     : Starting StrategyApplicationKt using Java 19.0.1 with PID 93660 (/home/sridhark/Downloads/strategy/build/classes/kotlin/main started by [email protected] in /home/sridhark/Downloads/strategy)
2023-07-11T12:57:47.139+05:30  INFO 93660 --- [           main] c.s.t.strategy.StrategyApplicationKt     : No active profile set, falling back to 1 default profile: "default"
2023-07-11T12:57:47.348+05:30 DEBUG 93660 --- [           main] o.s.d.n.repository.config.StartupLogger  : Bootstrapping reactive Neo4j repositories based on SDN v7.2.0-SNAPSHOT with Spring Data Commons v3.2.0-SNAPSHOT and Neo4j Driver v5.9.0.
2023-07-11T12:57:47.348+05:30  INFO 93660 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Neo4j repositories in DEFAULT mode.
2023-07-11T12:57:47.392+05:30  INFO 93660 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 42 ms. Found 0 Neo4j repository interfaces.
2023-07-11T12:57:47.395+05:30 DEBUG 93660 --- [           main] o.s.d.n.repository.config.StartupLogger  : Bootstrapping imperative Neo4j repositories based on SDN v7.2.0-SNAPSHOT with Spring Data Commons v3.2.0-SNAPSHOT and Neo4j Driver v5.9.0.
2023-07-11T12:57:47.395+05:30  INFO 93660 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Neo4j repositories in DEFAULT mode.
2023-07-11T12:57:47.403+05:30  INFO 93660 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 7 ms. Found 3 Neo4j repository interfaces.
2023-07-11T12:57:47.564+05:30  INFO 93660 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port 8080 (http)
2023-07-11T12:57:47.568+05:30  INFO 93660 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2023-07-11T12:57:47.568+05:30  INFO 93660 --- [           main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.10]
2023-07-11T12:57:47.600+05:30  INFO 93660 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2023-07-11T12:57:47.601+05:30  INFO 93660 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 439 ms
2023-07-11T12:57:47.673+05:30  INFO 93660 --- [           main] o.neo4j.driver.internal.DriverFactory    : Routing driver instance 1964335680 created for server address localhost:7687
2023-07-11T12:57:47.783+05:30  WARN 93660 --- [           main] o.s.d.n.c.mapping.Neo4jPersistentEntity  : The entity com.strategies.test1.strategy.model.StrategyEnder is using a Long value for storing internally generated Neo4j ids. The Neo4j internal Long Ids are deprecated, please consider using an external ID generator.
2023-07-11T12:57:47.788+05:30  WARN 93660 --- [           main] o.s.d.n.c.mapping.Neo4jPersistentEntity  : The entity com.strategies.test1.strategy.model.SignalCollector is using a Long value for storing internally generated Neo4j ids. The Neo4j internal Long Ids are deprecated, please consider using an external ID generator.
2023-07-11T12:57:47.789+05:30  WARN 93660 --- [           main] o.s.d.n.c.mapping.Neo4jPersistentEntity  : The entity com.strategies.test1.strategy.model.SignalGenerator is using a Long value for storing internally generated Neo4j ids. The Neo4j internal Long Ids are deprecated, please consider using an external ID generator.
2023-07-11T12:57:47.789+05:30  WARN 93660 --- [           main] o.s.d.n.c.mapping.Neo4jPersistentEntity  : The entity com.strategies.test1.strategy.model.ConditionCheckerCollector is using a Long value for storing internally generated Neo4j ids. The Neo4j internal Long Ids are deprecated, please consider using an external ID generator.
2023-07-11T12:57:47.790+05:30  WARN 93660 --- [           main] o.s.d.n.c.mapping.Neo4jPersistentEntity  : The entity com.strategies.test1.strategy.model.ConditionChecker is using a Long value for storing internally generated Neo4j ids. The Neo4j internal Long Ids are deprecated, please consider using an external ID generator.
2023-07-11T12:57:47.790+05:30  WARN 93660 --- [           main] o.s.d.n.c.mapping.Neo4jPersistentEntity  : The entity com.strategies.test1.strategy.model.CalculatorCollector is using a Long value for storing internally generated Neo4j ids. The Neo4j internal Long Ids are deprecated, please consider using an external ID generator.
2023-07-11T12:57:47.791+05:30  WARN 93660 --- [           main] o.s.d.n.c.mapping.Neo4jPersistentEntity  : The entity com.strategies.test1.strategy.model.Calculator is using a Long value for storing internally generated Neo4j ids. The Neo4j internal Long Ids are deprecated, please consider using an external ID generator.
2023-07-11T12:57:47.794+05:30  WARN 93660 --- [           main] o.s.d.n.c.mapping.Neo4jPersistentEntity  : The entity com.strategies.test1.strategy.model.NoTrend is using a Long value for storing internally generated Neo4j ids. The Neo4j internal Long Ids are deprecated, please consider using an external ID generator.
2023-07-11T12:57:47.797+05:30  WARN 93660 --- [           main] o.s.d.n.c.mapping.Neo4jPersistentEntity  : The entity com.strategies.test1.strategy.githubissues.WebDRetriever is using a Long value for storing internally generated Neo4j ids. The Neo4j internal Long Ids are deprecated, please consider using an external ID generator.
2023-07-11T12:57:47.802+05:30  WARN 93660 --- [           main] o.s.d.n.c.mapping.Neo4jPersistentEntity  : The entity com.zen.neo.NeoTestKotlinNew.model.DataCollector is using a Long value for storing internally generated Neo4j ids. The Neo4j internal Long Ids are deprecated, please consider using an external ID generator.
2023-07-11T12:57:47.802+05:30  WARN 93660 --- [           main] o.s.d.n.c.mapping.Neo4jPersistentEntity  : The entity com.strategies.test1.strategy.model.TickDataProcessor is using a Long value for storing internally generated Neo4j ids. The Neo4j internal Long Ids are deprecated, please consider using an external ID generator.
2023-07-11T12:57:47.804+05:30  WARN 93660 --- [           main] o.s.d.n.c.mapping.Neo4jPersistentEntity  : The entity com.strategies.test1.strategy.model.UpTrend is using a Long value for storing internally generated Neo4j ids. The Neo4j internal Long Ids are deprecated, please consider using an external ID generator.
2023-07-11T12:57:47.806+05:30  WARN 93660 --- [           main] o.s.d.n.c.mapping.Neo4jPersistentEntity  : The entity com.strategies.test1.strategy.model.Hold is using a Long value for storing internally generated Neo4j ids. The Neo4j internal Long Ids are deprecated, please consider using an external ID generator.
2023-07-11T12:57:47.809+05:30  WARN 93660 --- [           main] o.s.d.n.c.mapping.Neo4jPersistentEntity  : The entity com.strategies.test1.strategy.model.DownTrend is using a Long value for storing internally generated Neo4j ids. The Neo4j internal Long Ids are deprecated, please consider using an external ID generator.
2023-07-11T12:57:47.812+05:30  WARN 93660 --- [           main] o.s.d.n.c.mapping.Neo4jPersistentEntity  : The entity com.strategies.test1.strategy.githubissues.Starter is using a Long value for storing internally generated Neo4j ids. The Neo4j internal Long Ids are deprecated, please consider using an external ID generator.
2023-07-11T12:57:47.815+05:30  WARN 93660 --- [           main] o.s.d.n.c.mapping.Neo4jPersistentEntity  : The entity com.strategies.test1.strategy.model.StrategyStarter is using a Long value for storing internally generated Neo4j ids. The Neo4j internal Long Ids are deprecated, please consider using an external ID generator.
2023-07-11T12:57:47.816+05:30  WARN 93660 --- [           main] o.s.d.n.c.mapping.Neo4jPersistentEntity  : The entity com.strategies.test1.strategy.githubissues.WebDProcessor is using a Long value for storing internally generated Neo4j ids. The Neo4j internal Long Ids are deprecated, please consider using an external ID generator.
2023-07-11T12:57:48.029+05:30  WARN 93660 --- [           main] o.s.d.n.c.mapping.Neo4jPersistentEntity  : The entity com.zen.neo.NeoTestKotlinNew.model.TickDataRetriever is using a Long value for storing internally generated Neo4j ids. The Neo4j internal Long Ids are deprecated, please consider using an external ID generator.
2023-07-11T12:57:48.045+05:30  INFO 93660 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port 8080 (http) with context path ''
2023-07-11T12:57:48.048+05:30  INFO 93660 --- [           main] c.s.t.strategy.StrategyApplicationKt     : Started StrategyApplicationKt in 1.04 seconds (process running for 1.202)
2023-07-11T12:57:56.516+05:30  INFO 93660 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2023-07-11T12:57:56.516+05:30  INFO 93660 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2023-07-11T12:57:56.517+05:30  INFO 93660 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms
2023-07-11T12:57:56.550+05:30 DEBUG 93660 --- [nio-8080-exec-1] o.s.data.neo4j.core.Neo4jTemplate        : Saving entities using single statements.
2023-07-11T12:57:56.600+05:30 DEBUG 93660 --- [nio-8080-exec-1] org.springframework.data.neo4j.cypher    : Executing:
OPTIONAL MATCH (hlp:`Starter`) WHERE id(hlp) = $__id__ WITH hlp WHERE hlp IS NULL CREATE (starter:`Starter`) SET starter = $__properties__ RETURN starter UNION MATCH (starter:`Starter`) WHERE id(starter) = $__id__ SET starter += $__properties__ RETURN starter
2023-07-11T12:57:56.758+05:30 DEBUG 93660 --- [nio-8080-exec-1] org.springframework.data.neo4j.cypher    : Executing:
OPTIONAL MATCH (hlp:`WebDataRetriever`:`DataRetriever`) WHERE id(hlp) = $__id__ WITH hlp WHERE hlp IS NULL CREATE (webDRetriever:`WebDataRetriever`:`DataRetriever`) SET webDRetriever = $__properties__ RETURN webDRetriever UNION MATCH (webDRetriever:`WebDataRetriever`:`DataRetriever`) WHERE id(webDRetriever) = $__id__ SET webDRetriever += $__properties__ RETURN webDRetriever
2023-07-11T12:57:56.792+05:30 DEBUG 93660 --- [nio-8080-exec-1] org.springframework.data.neo4j.cypher    : Executing:
OPTIONAL MATCH (hlp:`WebDataProcessor`:`DataProcessor`) WHERE id(hlp) = $__id__ WITH hlp WHERE hlp IS NULL CREATE (webDProcessor:`WebDataProcessor`:`DataProcessor`) SET webDProcessor = $__properties__ RETURN webDProcessor UNION MATCH (webDProcessor:`WebDataProcessor`:`DataProcessor`) WHERE id(webDProcessor) = $__id__ SET webDProcessor += $__properties__ RETURN webDProcessor
2023-07-11T12:57:56.831+05:30 DEBUG 93660 --- [nio-8080-exec-1] org.springframework.data.neo4j.cypher    : Executing:
UNWIND $__relationships__ AS relationship WITH relationship MATCH (startNode) WHERE id(startNode) = relationship.fromId MATCH (endNode) WHERE id(endNode) = relationship.toId MERGE (startNode)-[relProps:`DATA_PROCESSED_BY`]->(endNode) RETURN toString(id(relProps)) AS __elementId__
2023-07-11T12:57:56.854+05:30 DEBUG 93660 --- [nio-8080-exec-1] org.springframework.data.neo4j.cypher    : Executing:
UNWIND $__relationships__ AS relationship WITH relationship MATCH (startNode) WHERE id(startNode) = relationship.fromId MATCH (endNode) WHERE id(endNode) = relationship.toId MERGE (startNode)-[relProps:`RETRIEVES`]->(endNode) RETURN toString(id(relProps)) AS __elementId__

image

After Executing endpoint "localhost:8080\getit"

2023-07-11T12:58:05.812+05:30 DEBUG 93660 --- [nio-8080-exec-2] org.springframework.data.neo4j.cypher    : Executing:
MATCH (starter:`Starter`) WHERE starter.name = $name RETURN starter{.name, __nodeLabels__: labels(starter), __internalNeo4jId__: id(starter), __elementId__: toString(id(starter)), Starter_RETRIEVES_DataRetriever: [(starter)-[:`RETRIEVES`]->(starter_dataRetriever:`DataRetriever`) | starter_dataRetriever{__allProperties__: starter_dataRetriever{.*}, __nodeLabels__: labels(starter_dataRetriever), __elementId__: toString(id(starter_dataRetriever))}]}
2023-07-11T12:58:05.841+05:30  WARN 93660 --- [nio-8080-exec-2] .n.c.Neo4jPersistenceExceptionTranslator : Don't know how to translate exception of type class org.springframework.data.mapping.MappingException
2023-07-11T12:58:05.846+05:30 ERROR 93660 --- [nio-8080-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.springframework.data.mapping.MappingException: Error mapping Record<{starter: {name: "St", __internalNeo4jId__: 9, Starter_RETRIEVES_DataRetriever: [{__allProperties__: {name: "webdr", src1: "getSrc1", src2: "getSrc2"}, __elementId__: "10", __nodeLabels__: ["DataRetriever", "WebDataRetriever"]}], __elementId__: "9", __nodeLabels__: ["Starter"]}}>] with root cause

java.lang.NullPointerException: Parameter specified as non-null is null: method com.strategies.test1.strategy.githubissues.WebDRetriever.<init>, parameter dataProcessor
	at com.strategies.test1.strategy.githubissues.WebDRetriever.<init>(WebDRetriever.kt) ~[main/:na]
	at com.strategies.test1.strategy.githubissues.WebDRetriever_Instantiator_76jh55.newInstance(Unknown Source) ~[main/:na]
	at org.springframework.data.mapping.model.ClassGeneratingEntityInstantiator$EntityInstantiatorAdapter.createInstance(ClassGeneratingEntityInstantiator.java:276) ~[spring-data-commons-3.2.0-SNAPSHOT.jar:3.2.0-SNAPSHOT]
	at org.springframework.data.mapping.model.ClassGeneratingEntityInstantiator.createInstance(ClassGeneratingEntityInstantiator.java:98) ~[spring-data-commons-3.2.0-SNAPSHOT.jar:3.2.0-SNAPSHOT]
	at org.springframework.data.neo4j.core.mapping.DefaultNeo4jEntityConverter.instantiate(DefaultNeo4jEntityConverter.java:491) ~[spring-data-neo4j-7.2.0-SNAPSHOT.jar:7.2.0-SNAPSHOT]
	at org.springframework.data.neo4j.core.mapping.DefaultNeo4jEntityConverter.lambda$map$2(DefaultNeo4jEntityConverter.java:324) ~[spring-data-neo4j-7.2.0-SNAPSHOT.jar:7.2.0-SNAPSHOT]
	at org.springframework.data.neo4j.core.mapping.DefaultNeo4jEntityConverter.map(DefaultNeo4jEntityConverter.java:343) ~[spring-data-neo4j-7.2.0-SNAPSHOT.jar:7.2.0-SNAPSHOT]
	at org.springframework.data.neo4j.core.mapping.DefaultNeo4jEntityConverter.createInstanceOfRelationships(DefaultNeo4jEntityConverter.java:749) ~[spring-data-neo4j-7.2.0-SNAPSHOT.jar:7.2.0-SNAPSHOT]
	at org.springframework.data.neo4j.core.mapping.DefaultNeo4jEntityConverter.createInstanceOfRelationships(DefaultNeo4jEntityConverter.java:613) ~[spring-data-neo4j-7.2.0-SNAPSHOT.jar:7.2.0-SNAPSHOT]
	at org.springframework.data.neo4j.core.mapping.DefaultNeo4jEntityConverter$1.getParameterValue(DefaultNeo4jEntityConverter.java:466) ~[spring-data-neo4j-7.2.0-SNAPSHOT.jar:7.2.0-SNAPSHOT]
	at org.springframework.data.mapping.model.ClassGeneratingEntityInstantiator.extractInvocationArguments(ClassGeneratingEntityInstantiator.java:301) ~[spring-data-commons-3.2.0-SNAPSHOT.jar:3.2.0-SNAPSHOT]
	at org.springframework.data.mapping.model.ClassGeneratingEntityInstantiator$EntityInstantiatorAdapter.createInstance(ClassGeneratingEntityInstantiator.java:273) ~[spring-data-commons-3.2.0-SNAPSHOT.jar:3.2.0-SNAPSHOT]
	at org.springframework.data.mapping.model.ClassGeneratingEntityInstantiator.createInstance(ClassGeneratingEntityInstantiator.java:98) ~[spring-data-commons-3.2.0-SNAPSHOT.jar:3.2.0-SNAPSHOT]
	at org.springframework.data.neo4j.core.mapping.DefaultNeo4jEntityConverter.instantiate(DefaultNeo4jEntityConverter.java:491) ~[spring-data-neo4j-7.2.0-SNAPSHOT.jar:7.2.0-SNAPSHOT]
	at org.springframework.data.neo4j.core.mapping.DefaultNeo4jEntityConverter.lambda$map$2(DefaultNeo4jEntityConverter.java:324) ~[spring-data-neo4j-7.2.0-SNAPSHOT.jar:7.2.0-SNAPSHOT]
	at org.springframework.data.neo4j.core.mapping.DefaultNeo4jEntityConverter.map(DefaultNeo4jEntityConverter.java:343) ~[spring-data-neo4j-7.2.0-SNAPSHOT.jar:7.2.0-SNAPSHOT]
	at org.springframework.data.neo4j.core.mapping.DefaultNeo4jEntityConverter.map(DefaultNeo4jEntityConverter.java:301) ~[spring-data-neo4j-7.2.0-SNAPSHOT.jar:7.2.0-SNAPSHOT]
	at org.springframework.data.neo4j.core.mapping.DefaultNeo4jEntityConverter.read(DefaultNeo4jEntityConverter.java:121) ~[spring-data-neo4j-7.2.0-SNAPSHOT.jar:7.2.0-SNAPSHOT]
	at org.springframework.data.neo4j.core.mapping.DefaultNeo4jEntityConverter.read(DefaultNeo4jEntityConverter.java:71) ~[spring-data-neo4j-7.2.0-SNAPSHOT.jar:7.2.0-SNAPSHOT]
	at org.springframework.data.neo4j.core.mapping.Schema.lambda$getRequiredMappingFunctionFor$0(Schema.java:96) ~[spring-data-neo4j-7.2.0-SNAPSHOT.jar:7.2.0-SNAPSHOT]
	at org.springframework.data.neo4j.core.PreparedQuery$AggregatingMappingFunction.apply(PreparedQuery.java:246) ~[spring-data-neo4j-7.2.0-SNAPSHOT.jar:7.2.0-SNAPSHOT]
	at org.springframework.data.neo4j.core.PreparedQuery$AggregatingMappingFunction.apply(PreparedQuery.java:158) ~[spring-data-neo4j-7.2.0-SNAPSHOT.jar:7.2.0-SNAPSHOT]
	at org.springframework.data.neo4j.core.DefaultNeo4jClient$DefaultRecordFetchSpec.one(DefaultNeo4jClient.java:453) ~[spring-data-neo4j-7.2.0-SNAPSHOT.jar:7.2.0-SNAPSHOT]
	at java.base/java.util.Optional.flatMap(Optional.java:289) ~[na:na]
	at org.springframework.data.neo4j.core.Neo4jTemplate$DefaultExecutableQuery.getSingleResult(Neo4jTemplate.java:1111) ~[spring-data-neo4j-7.2.0-SNAPSHOT.jar:7.2.0-SNAPSHOT]
	at org.springframework.data.neo4j.repository.query.Neo4jQueryExecution$DefaultQueryExecution.execute(Neo4jQueryExecution.java:53) ~[spring-data-neo4j-7.2.0-SNAPSHOT.jar:7.2.0-SNAPSHOT]
	at org.springframework.data.neo4j.repository.query.AbstractNeo4jQuery.execute(AbstractNeo4jQuery.java:93) ~[spring-data-neo4j-7.2.0-SNAPSHOT.jar:7.2.0-SNAPSHOT]
	at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke(RepositoryMethodInvoker.java:136) ~[spring-data-commons-3.2.0-SNAPSHOT.jar:3.2.0-SNAPSHOT]
	at org.springframework.data.repository.core.support.RepositoryMethodInvoker.invoke(RepositoryMethodInvoker.java:120) ~[spring-data-commons-3.2.0-SNAPSHOT.jar:3.2.0-SNAPSHOT]
	at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:164) ~[spring-data-commons-3.2.0-SNAPSHOT.jar:3.2.0-SNAPSHOT]
	at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:143) ~[spring-data-commons-3.2.0-SNAPSHOT.jar:3.2.0-SNAPSHOT]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184) ~[spring-aop-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:72) ~[spring-data-commons-3.2.0-SNAPSHOT.jar:3.2.0-SNAPSHOT]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184) ~[spring-aop-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123) ~[spring-tx-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:392) ~[spring-tx-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119) ~[spring-tx-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184) ~[spring-aop-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137) ~[spring-tx-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184) ~[spring-aop-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97) ~[spring-aop-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184) ~[spring-aop-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at org.springframework.data.repository.core.support.MethodInvocationValidator.invoke(MethodInvocationValidator.java:95) ~[spring-data-commons-3.2.0-SNAPSHOT.jar:3.2.0-SNAPSHOT]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184) ~[spring-aop-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:244) ~[spring-aop-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at jdk.proxy2/jdk.proxy2.$Proxy86.findByName(Unknown Source) ~[na:na]
	at com.strategies.test1.strategy.githubissues.BuildDemo.getit(BuildDemo.kt:33) ~[main/:na]
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:578) ~[na:na]
	at kotlin.reflect.jvm.internal.calls.CallerImpl$Method.callMethod(CallerImpl.kt:97) ~[kotlin-reflect-1.8.22.jar:1.8.22-release-407(1.8.22)]
	at kotlin.reflect.jvm.internal.calls.CallerImpl$Method$Instance.call(CallerImpl.kt:113) ~[kotlin-reflect-1.8.22.jar:1.8.22-release-407(1.8.22)]
	at kotlin.reflect.jvm.internal.KCallableImpl.callDefaultMethod$kotlin_reflection(KCallableImpl.kt:188) ~[kotlin-reflect-1.8.22.jar:1.8.22-release-407(1.8.22)]
	at kotlin.reflect.jvm.internal.KCallableImpl.callBy(KCallableImpl.kt:111) ~[kotlin-reflect-1.8.22.jar:1.8.22-release-407(1.8.22)]
	at org.springframework.web.method.support.InvocableHandlerMethod$KotlinDelegate.invokeFunction(InvocableHandlerMethod.java:318) ~[spring-web-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:250) ~[spring-web-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:181) ~[spring-web-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:118) ~[spring-webmvc-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:918) ~[spring-webmvc-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:830) ~[spring-webmvc-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1086) ~[spring-webmvc-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:979) ~[spring-webmvc-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1011) ~[spring-webmvc-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:903) ~[spring-webmvc-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:564) ~[tomcat-embed-core-10.1.10.jar:6.0]
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:885) ~[spring-webmvc-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658) ~[tomcat-embed-core-10.1.10.jar:6.0]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:205) ~[tomcat-embed-core-10.1.10.jar:10.1.10]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.10.jar:10.1.10]
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) ~[tomcat-embed-websocket-10.1.10.jar:10.1.10]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.10.jar:10.1.10]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.10.jar:10.1.10]
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.10.jar:10.1.10]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.10.jar:10.1.10]
	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.10.jar:10.1.10]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.10.jar:10.1.10]
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.1.0-SNAPSHOT.jar:6.1.0-SNAPSHOT]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.10.jar:10.1.10]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.10.jar:10.1.10]
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:166) ~[tomcat-embed-core-10.1.10.jar:10.1.10]
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90) ~[tomcat-embed-core-10.1.10.jar:10.1.10]
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482) ~[tomcat-embed-core-10.1.10.jar:10.1.10]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115) ~[tomcat-embed-core-10.1.10.jar:10.1.10]
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93) ~[tomcat-embed-core-10.1.10.jar:10.1.10]
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) ~[tomcat-embed-core-10.1.10.jar:10.1.10]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:341) ~[tomcat-embed-core-10.1.10.jar:10.1.10]
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391) ~[tomcat-embed-core-10.1.10.jar:10.1.10]
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63) ~[tomcat-embed-core-10.1.10.jar:10.1.10]
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:894) ~[tomcat-embed-core-10.1.10.jar:10.1.10]
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1741) ~[tomcat-embed-core-10.1.10.jar:10.1.10]
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) ~[tomcat-embed-core-10.1.10.jar:10.1.10]
	at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) ~[tomcat-embed-core-10.1.10.jar:10.1.10]
	at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) ~[tomcat-embed-core-10.1.10.jar:10.1.10]
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-10.1.10.jar:10.1.10]
	at java.base/java.lang.Thread.run(Thread.java:1589) ~[na:na]

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jul 11, 2023
@Kanish2002
Copy link
Author

Kanish2002 commented Jul 11, 2023

Actually I added the whole code, then stored graph after executing the code, and Exception I got while retrieving it from the database.

@meistermeier
Copy link
Collaborator

Thanks. This clarifies a lot.
It fails because the logical chain is Starter->DRetriever->DProcessor, given by the type definitions in the constructors of your domain classes.
Starter (as a class) defines the relationship to DRetriever. SDN can correctly map this but it looks only into DRetriever (the interface) to determine all needed relationships to fetch. There are none. That's why the DProcessor never gets filled.
The current state is that you can use interfaces in SDN for additional labelling of specific types, but you cannot use as complete (abstract) class replacements. Let's take the WebDataRetriever as an example. In your application, it is pretty obvious that it has only one parent.
But you could also have n parent entities, e.g. DataRetriever and SomethingWithData. At this point there is direct no hierarchy in place and SDN would need to walk from DataRetriever to WebDataRetriever (and its other implementations) to SomethingWithData (which might also extend other interfaces) to figure out which relationships to fetch.
That's why we only support this for (abstract) classes at the moment.
If your model is really single parent hierarchy, I would suggest solving this with abstract classes for the given interfaces.

@meistermeier meistermeier added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Jul 12, 2023
@Kanish2002
Copy link
Author

Kanish2002 commented Jul 13, 2023

Thanks @meistermeier for the response.
yeah my model is single parent hierarchy, I will try this with abstract classes.

Actually while surfing on internet regarding this interface Problem I came to know about this github repo mentioned below.

https://github.com/meistermeier/neo4j-issues-examples/tree/master/discourse-63046/src/main/java/com/example/discourse63046

I will try using abstract classes and update you about that soon..

As of my understanding after your comment is interfaces are mainly used for multiple labels right, but in the reference doc it is given like I can give a parent type as a interface, can you please give me a clear understanding if I'm wrong.

https://docs.spring.io/spring-data/neo4j/docs/current/reference/html/#mapping.annotations.node

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jul 13, 2023
@meistermeier
Copy link
Collaborator

I have to admit that the documentation (with the getRelated method declared) is misleading in this case.
Will keep this issue open to either (just) adjust the documentation or explore the options to bring this into SDN as a full supported feature. But this will require me to reflect on the impact first if there could be more than just one parent.
Currently SDN is pretty stable when it comes to property and relationship detection up and down the hierarchy, and I don't wan't it to become unstable.

Conclusion is: It is not a bug per-se but somehow really misleading example. It comes directly from our test sources but the test (obviously) only checks for the specific implementation instances of the interfaces but not the relationships within.

On a personal note: Don't feel ignored over the next weeks since I will be on vacation and will continue on this when I come back.

@meistermeier meistermeier added the status: needs-investigation An issue that has been triaged but needs further investigation label Jul 13, 2023
@Kanish2002
Copy link
Author

Thanks @meistermeier I understand that the docs misleads me, please let me know after docs are updated.

@meistermeier
Copy link
Collaborator

meistermeier commented Dec 14, 2023

It took a "little bit" longer to answer here because there were #2788 coming that also addressed better (node-annotated) interface support. And after I added this, I completely forgot to give an answer to your last comment.
With this, the documentation does not need to get changed and it should also work for you.

@meistermeier meistermeier added status: waiting-for-feedback We need additional information before we can continue and removed status: needs-investigation An issue that has been triaged but needs further investigation status: feedback-provided Feedback has been provided labels Dec 14, 2023
@spring-projects-issues
Copy link

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Dec 21, 2023
@Kanish2002
Copy link
Author

Hi @meistermeier
Thanks for the reply,
Is that issue resolved in the current version of SDN ?
if resolved I should be able to use annotated interface with data classes of kotlin , am I right !?

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue labels Dec 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: feedback-provided Feedback has been provided
Projects
None yet
Development

No branches or pull requests

3 participants