-
Notifications
You must be signed in to change notification settings - Fork 617
Description
Hello,
Having the following object models (I am using Kotlin):
interface Movie {
val id: String
val name: String
}
@Node("AnimationMovie")
class AnimationMovie(@Id override val id: String, override val name: String, val studio: String): Movie
@Node("Cinema")
class Cinema(@Id val id: String, val name: String,
@Relationship("Plays", direction = Relationship.Direction.OUTGOING) val plays: List<Movie>
)
Along with the following repository:
interface CinemaRepository: Neo4jRepository<Cinema, String>
My database is setup as follows:
CREATE (:AnimationMovie {id: 'movie001', name: 'movie-001', studio: 'Pixar'})<-[:Plays]-(:Cinema {id:'cine-01', name: 'GrandRex'})
The cinema object returned by cinemaRepository.findAll() doesn't contain any movie in the plays field. If that field is declared as List<AnimationMovie>
instead of List<Movie>
, it works as expected and the relation is fulfilled... But I really want to be able to play different kinds of movies !
If I add a Movie label to the AnimationMovie (as in CREATE (:Movie:AnimationMovie {id: 'movie001', name: 'movie-001', studio: 'Pixar'})<-[:Plays]-(:Cinema {id:'cine-01', name: 'GrandRex'})
), I get the following error:
Failed to instantiate [Movie]: Specified class is an interface
spring-data-neo4j version: 6.0.8
Any help would be highly appreciated !
Sylvain