Inheritance in SDN6

I have a small inheritance problem in Spring Data Neo4j 6.1.4.

Notification is an abstract class and RequestNotification is one of the supertypes.

interface NotificationRepository : Neo4jRepository<Notification, Long> {
   fun findByNotificationId(notificationId: Long): Notification?

In SDN5 I could then use the returned object and see the exact type.

val notification = findNotificationById(notificationId)
if(notification !is RequestNotification)
   throw IllegalArgumentException()

This can't be done after migrating to SDN6 anymore. I am getting the exception thrown, that means that Notification is not a subtype of RequestNotification.

In the database, the nodes have correct labels (i.e. Notification and RequestNotification.)
In the documentation, I couldn't see the answer to this.

What are my options?

This should work. I am expecting the notification to have another possible type because otherwise SDN would fail on creating the object if there is no concrete class available.
Could you please post your domain model?

Also note that in the section Node mapping there is a sub-section called A note on class hierarchies that might clarify things.

1 Like

Thanks for answering, I had seen the mentioned subsection before, but I needed to have a fresh look at it. I solved the issue by adding the "@Node" annotation to the supertype.

These classes worked in SDN5

class Notification(...)

class RequestNotification(...)

These classes are woking now in SDN6.

class Notification(...)

class RequestNotification(...)