@@ -47,7 +47,7 @@ public VirtualNode(Label[] labels, Map<String, Object> props) {
47
47
this .id = MIN_ID .decrementAndGet ();
48
48
addLabels (asList (labels ));
49
49
this .props .putAll (props );
50
- this .elementId = null ;
50
+ this .elementId = UUID . randomUUID (). toString () ;
51
51
}
52
52
53
53
@ SuppressWarnings ("unused" ) // used from extended
@@ -65,15 +65,17 @@ public VirtualNode(long nodeId) {
65
65
66
66
public VirtualNode (Node node , List <String > propertyNames , boolean wrapNodeIDs ) {
67
67
Objects .requireNonNull (node , ERROR_NODE_NULL );
68
- final long id = node .getId ();
69
- // if node is already virtual, we return the same id
70
- this .id = id < 0 || wrapNodeIDs ? id : -id - 1 ;
68
+ final long givenNodeId = node .getId ();
69
+ // if node is already virtual, we return the same id/element id
70
+ this .id = givenNodeId < 0 || wrapNodeIDs ? givenNodeId : -givenNodeId - 1 ;
71
+ this .elementId = givenNodeId < 0 || wrapNodeIDs
72
+ ? node .getElementId ()
73
+ : UUID .randomUUID ().toString ();
71
74
// to not overlap this nodes ids with ids from VirtualNode(Label[] labels, Map<String, Object> props)
72
75
MIN_ID .updateAndGet (x -> Math .min (x , this .id ));
73
76
this .labels .addAll (Util .labelStrings (node ));
74
77
String [] keys = propertyNames .toArray (new String [propertyNames .size ()]);
75
78
this .props .putAll (node .getProperties (keys ));
76
- this .elementId = node .getElementId ();
77
79
}
78
80
79
81
public VirtualNode (Node node , List <String > propertyNames ) {
0 commit comments