@@ -28,7 +28,7 @@ public class WithItem<K extends ParenthesedStatement> implements Serializable {
2828 private Alias alias ;
2929 private List <SelectItem <?>> withItemList ;
3030 private boolean recursive = false ;
31-
31+ private boolean usingNot = false ;
3232 private boolean materialized = false ;
3333
3434 public WithItem (K statement , Alias alias ) {
@@ -90,6 +90,24 @@ public void setMaterialized(boolean materialized) {
9090 this .materialized = materialized ;
9191 }
9292
93+ public K getStatement () {
94+ return statement ;
95+ }
96+
97+ public WithItem <K > setStatement (K statement ) {
98+ this .statement = statement ;
99+ return this ;
100+ }
101+
102+ public boolean isUsingNot () {
103+ return usingNot ;
104+ }
105+
106+ public WithItem <K > setUsingNot (boolean usingNot ) {
107+ this .usingNot = usingNot ;
108+ return this ;
109+ }
110+
93111 /**
94112 * The {@link SelectItem}s in this WITH (for example the A,B,C in "WITH mywith (A,B,C) AS ...")
95113 *
@@ -119,7 +137,11 @@ public String toString() {
119137 builder .append (")" );
120138 }
121139 builder .append (" AS " );
122- builder .append (materialized ? "MATERIALIZED " : "" );
140+ if (materialized ) {
141+ builder .append (usingNot
142+ ? "NOT MATERIALIZED "
143+ : "MATERIALIZED " );
144+ }
123145 builder .append (statement );
124146 return builder .toString ();
125147 }
@@ -144,6 +166,13 @@ public WithItem<?> withRecursive(boolean recursive, boolean materialized) {
144166 return this ;
145167 }
146168
169+ public WithItem <?> withRecursive (boolean recursive , boolean usingNot , boolean materialized ) {
170+ this .setRecursive (recursive );
171+ this .setUsingNot (usingNot );
172+ this .setMaterialized (materialized );
173+ return this ;
174+ }
175+
147176 public WithItem <?> addWithItemList (SelectItem <?>... withItemList ) {
148177 List <SelectItem <?>> collection =
149178 Optional .ofNullable (getWithItemList ()).orElseGet (ArrayList ::new );
0 commit comments