Commit 62496fc
committed
GH-2201 - Allow interfaces in domain model hierachies.
While technically possible, Spring Data Neo4j prevented a proper use of
interfaces in domain hierachies due to the fact that it checks whether a
primary label has been used already in a domain model. That check can be
triggered at different point in times: Either when initializing the
persistence context with a predefined set of entities or when an
interface based entity is refered from an implementation of itself.
This commit changes the following approaches:
* Interfaces won't contribute to the index of entities by primary label
* The explicit or implicit names of interfaces implemented by an entity
will contribute to the list of additional labels. However, we don't
traverse the graph of interfaces to the top
* When hydrating instances we must check whether the target is an
interface. If so, we go through the list of all known persistent
entities and look for one that can be assigned to the interface and
which spots all the mapped labels
In addition we fixed some bugs when selecting the target entity type
when saving relationships. Also, `@Relationship` without a given
relationship type name will work now without messing up the type name.
This allows for the following scenarios:
1. Creating an API module being free of Spring or Neo4j based
annotations. That API module can than be implemented by different
Spring Data stores that support interfaces in their hierachies like
we do now then.
2. Putting an explicit `@Node` annotation onto an interface so that the
implementation can be arbitrary named (Which is probably a rarer use
case).
3. Using polymorpmic relationships: If an interface has multiple
implementations in the same project, the interface and it's
implementations can both be annotated. The annotation on the
interface is going to be the primary label and the labels on the
annotated implementations are the selectors for picking out the class
to hydrate during loading.
This closes #2201.1 parent 38a269e commit 62496fc
File tree
14 files changed
+834
-108
lines changed- src
- main
- asciidoc/object-mapping
- java/org/springframework/data/neo4j/core
- mapping
- schema
- test/java/org/springframework/data/neo4j
- core/mapping
- integration
- imperative
14 files changed
+834
-108
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
| 78 | + | |
77 | 79 | | |
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
82 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
83 | 128 | | |
84 | 129 | | |
85 | 130 | | |
| |||
Lines changed: 3 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
526 | 526 | | |
527 | 527 | | |
528 | 528 | | |
529 | | - | |
530 | | - | |
| 529 | + | |
531 | 530 | | |
532 | 531 | | |
533 | 532 | | |
| |||
589 | 588 | | |
590 | 589 | | |
591 | 590 | | |
592 | | - | |
593 | | - | |
| 591 | + | |
594 | 592 | | |
595 | 593 | | |
596 | 594 | | |
| 595 | + | |
597 | 596 | | |
598 | 597 | | |
599 | 598 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
659 | 659 | | |
660 | 660 | | |
661 | 661 | | |
662 | | - | |
663 | | - | |
| 662 | + | |
664 | 663 | | |
665 | 664 | | |
666 | 665 | | |
| |||
736 | 735 | | |
737 | 736 | | |
738 | 737 | | |
739 | | - | |
| 738 | + | |
740 | 739 | | |
741 | 740 | | |
742 | 741 | | |
743 | 742 | | |
744 | 743 | | |
| 744 | + | |
745 | 745 | | |
746 | 746 | | |
747 | 747 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
248 | | - | |
| 248 | + | |
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
| |||
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
309 | | - | |
| 309 | + | |
310 | 310 | | |
311 | 311 | | |
312 | 312 | | |
| |||
Lines changed: 59 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
93 | | - | |
| 94 | + | |
94 | 95 | | |
95 | 96 | | |
96 | 97 | | |
| |||
206 | 207 | | |
207 | 208 | | |
208 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
209 | 214 | | |
210 | 215 | | |
211 | 216 | | |
| |||
300 | 305 | | |
301 | 306 | | |
302 | 307 | | |
| 308 | + | |
303 | 309 | | |
304 | 310 | | |
305 | | - | |
| 311 | + | |
| 312 | + | |
306 | 313 | | |
307 | | - | |
308 | | - | |
309 | | - | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
310 | 317 | | |
311 | 318 | | |
312 | 319 | | |
| |||
322 | 329 | | |
323 | 330 | | |
324 | 331 | | |
| 332 | + | |
| 333 | + | |
325 | 334 | | |
326 | 335 | | |
327 | 336 | | |
328 | 337 | | |
329 | 338 | | |
330 | 339 | | |
331 | 340 | | |
332 | | - | |
333 | | - | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
334 | 344 | | |
335 | 345 | | |
336 | 346 | | |
337 | 347 | | |
338 | 348 | | |
| 349 | + | |
| 350 | + | |
339 | 351 | | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
346 | 375 | | |
| 376 | + | |
| 377 | + | |
347 | 378 | | |
348 | 379 | | |
349 | 380 | | |
| |||
352 | 383 | | |
353 | 384 | | |
354 | 385 | | |
355 | | - | |
356 | | - | |
| 386 | + | |
357 | 387 | | |
358 | 388 | | |
359 | 389 | | |
| |||
363 | 393 | | |
364 | 394 | | |
365 | 395 | | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
366 | 410 | | |
367 | 411 | | |
368 | 412 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
130 | | - | |
| 131 | + | |
131 | 132 | | |
132 | 133 | | |
133 | 134 | | |
| |||
0 commit comments