2626import java .util .HashMap ;
2727import java .util .List ;
2828import java .util .Map ;
29- import java .util .stream .Collectors ;
3029
3130import static java .util .Collections .emptyList ;
3231import static java .util .Collections .emptyMap ;
3332import static java .util .Collections .unmodifiableMap ;
33+ import static java .util .stream .Collectors .toMap ;
34+ import static java .util .stream .Collectors .toUnmodifiableList ;
3435
3536/**
3637 * Base class for {@link RootGraph} and {@link SubGraph} implementations.
@@ -69,8 +70,15 @@ public final ManagedDomainType<J> getGraphedType() {
6970 }
7071 @ Override
7172 public List <jakarta .persistence .AttributeNode <?>> getAttributeNodes () {
72- //noinspection unchecked,rawtypes
73- return (List ) getAttributeNodeList ();
73+ if ( attributeNodes == null ) {
74+ return emptyList ();
75+ }
76+ else {
77+ // we need to filter out removed nodes
78+ return attributeNodes .values ().stream ()
79+ .filter ( (node ) -> !node .isRemoved () )
80+ .collect ( toUnmodifiableList ());
81+ }
7482 }
7583
7684
@@ -81,7 +89,9 @@ public List<AttributeNodeImplementor<?,?,?>> getAttributeNodeList() {
8189 }
8290 else {
8391 // we need to filter out removed nodes
84- return attributeNodes .values ().stream ().filter ( (node ) -> !node .isRemoved () ).toList ();
92+ return attributeNodes .values ().stream ()
93+ .filter ( (node ) -> !node .isRemoved () )
94+ .toList ();
8595 }
8696 }
8797
@@ -95,7 +105,7 @@ public List<AttributeNodeImplementor<?,?,?>> getAttributeNodeList() {
95105 .entrySet ()
96106 .stream ()
97107 .filter ( (entry ) -> !entry .getValue ().isRemoved () )
98- .collect ( Collectors . toMap ( Map .Entry ::getKey , Map .Entry ::getValue ) );
108+ .collect ( toMap ( Map .Entry ::getKey , Map .Entry ::getValue ) );
99109 }
100110 }
101111
0 commit comments