Reputation: 31
When saving the Dater
class below with Neo4jRepository::save
(spring-data-neo4j-6.1.5
) the save hangs and never returns. I believe it has something to do with my Dater
object having a relationship defined by a set referencing an interface instead of a class with a @Node
annotation. Is this an issue for neo4j?
//PersistentDaterMusicItem is interface. Is there a problem doing this?
@Relationship(type = "LISTENS_TO_MUSIC")
private Set<PersistentDaterMusicItem> musicItems = new HashSet<>();
//parent
@Node
public class Dater{
@Id
@GeneratedValue
//set of different implementations of PersistentDaterMusicItem
@Relationship(type = "LISTENS_TO_MUSIC")
private Set<PersistentDaterMusicItem> musicItems = new HashSet<>();
}
//inteface 1
public interface PersistentLibraryMusicItem extends PersistentDaterMusicItem{
LocalDateTime getAddedDateTime();
}
//interface 2
public interface PersistentListenedMusicItem extends PersistentDaterMusicItem{
LocalDateTime getListenedDateTime();
}
//impl 1 of PersistentDaterMusicItem
@Node
public class ListenedAppleSong extends AppleSong implements PersistentListenedMusicItem{
@Id
@GeneratedValue
private final Long id;
}
//impl 2 of PersistentDaterMusicItem
@Node
public class LibraryAppleSong extends AppleSong implements PersistentLibraryMusicItem{
@Id
@GeneratedValue
private final Long id;
}
Upvotes: 0
Views: 55
Reputation: 31
It turns out the problem was unrelated to what I thought. My constructor to ListenedAppleSong
took an argument that was not a field of the class. Since Spring data expects constructor args to exist as fields it was failing with error: "Required property appleSong not found for class com.dapp.common.model.apple.ListenedAppleSong!"
Solution was to make sure all constructor args are fields in the class. Unfortunately this error was not thrown during execution and the code just hung so it took a while to debug.
Upvotes: 0