1515import java .util .Iterator ;
1616import java .util .List ;
1717import java .util .Optional ;
18+
1819import static java .util .stream .Collectors .joining ;
1920import net .sf .jsqlparser .expression .Expression ;
2021import net .sf .jsqlparser .expression .OracleHint ;
@@ -33,6 +34,7 @@ public class Delete implements Statement {
3334 private Table table ;
3435 private OracleHint oracleHint = null ;
3536 private List <Table > tables ;
37+ private List <Table > usingList ;
3638 private List <Join > joins ;
3739 private Expression where ;
3840 private Limit limit ;
@@ -116,6 +118,14 @@ public void setTables(List<Table> tables) {
116118 this .tables = tables ;
117119 }
118120
121+ public List <Table > getUsingList () {
122+ return usingList ;
123+ }
124+
125+ public void setUsingList (List <Table > usingList ) {
126+ this .usingList = usingList ;
127+ }
128+
119129 public List <Join > getJoins () {
120130 return joins ;
121131 }
@@ -162,6 +172,13 @@ public String toString() {
162172 }
163173 b .append (" " ).append (table );
164174
175+ if (usingList != null && usingList .size ()>0 ) {
176+ b .append (" USING " );
177+ b .append (usingList .stream ()
178+ .map (Table ::toString )
179+ .collect (joining (", " )));
180+ }
181+
165182 if (joins != null ) {
166183 for (Join join : joins ) {
167184 if (join .isSimple ()) {
@@ -191,6 +208,11 @@ public Delete withTables(List<Table> tables) {
191208 return this ;
192209 }
193210
211+ public Delete withUsingList (List <Table > usingList ) {
212+ this .setUsingList (usingList );
213+ return this ;
214+ }
215+
194216 public Delete withJoins (List <Join > joins ) {
195217 this .setJoins (joins );
196218 return this ;
@@ -233,6 +255,18 @@ public Delete addTables(Collection<? extends Table> tables) {
233255 return this .withTables (collection );
234256 }
235257
258+ public Delete addUsingList (Table ... usingList ) {
259+ List <Table > collection = Optional .ofNullable (getUsingList ()).orElseGet (ArrayList ::new );
260+ Collections .addAll (collection , usingList );
261+ return this .withUsingList (collection );
262+ }
263+
264+ public Delete addUsingList (Collection <? extends Table > usingList ) {
265+ List <Table > collection = Optional .ofNullable (getUsingList ()).orElseGet (ArrayList ::new );
266+ collection .addAll (usingList );
267+ return this .withUsingList (collection );
268+ }
269+
236270 public Delete addJoins (Join ... joins ) {
237271 List <Join > collection = Optional .ofNullable (getJoins ()).orElseGet (ArrayList ::new );
238272 Collections .addAll (collection , joins );
0 commit comments