neo4j / sdn-rx

Nextgen Spring Data module for Neo4j supporting (not only) reactive data access and immutable support
https://neo4j.github.io/sdn-rx
Apache License 2.0
65 stars 23 forks source link

Throw exception if class hierarchy has more than one Node annotation #147

Closed meistermeier closed 4 years ago

meistermeier commented 4 years ago

There should be a check in place during initialization to look for "inherited" @Node annotations. If this is the case it should throw a matching exception and not start the application at all.

meistermeier commented 4 years ago

Discussion about label inheritance on the community site: https://community.neo4j.com/t/inheritance-in-sdn-rx/14916/2

meistermeier commented 4 years ago

The downside of this approach would be to introduce a (more complex) hierarchy scanning. An entity does not need to have a @Node annotation to get mapped later in the process and its label will get derived from its class name. Assuming we would have a constellation like this:

@Node("baseLabel")
class BaseClass {}

class User extends BaseClass {}

should this fail? I would say no but with only baseLabel it is not possible to find out what the target entity is for loading.

Suggestion: No @Node in parent classes allowed. So if at least one extending class exists, the application will not start.

meistermeier commented 4 years ago

We will remove the @Inherited attribute on the @Node annotation and log a warning if a user relies on inheritance for multi label. Reminder: Multi labels can only be used by defining them on the most concrete class.

meistermeier commented 4 years ago

We decided to move into the opposite direction and allow the reflection of inheritance in the Java domain model to the database. This issue is closed by #165