-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathJoin.java
More file actions
151 lines (112 loc) · 3.15 KB
/
Copy pathJoin.java
File metadata and controls
151 lines (112 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
package advancedsql.query.join;
import advancedsql.query.Select;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
public class Join implements IJoin {
protected Select query = null;
protected String table = null;
protected String on = null;
protected String as = null;
protected String[] using = null;
public Join(Select query, String table) {
this.query = query;
this.table = table;
}
@Override
public IJoin on(String conditional) {
this.on = conditional;
return this;
}
@Override
public IJoin as(String name) {
this.as = name;
return this;
}
@Override
public IJoin using(String[] columns) {
this.using = columns;
return this;
}
@Override
public IJoin join(String table) {
return this.query.join(table);
}
@Override
public IJoin innerJoin(String table) {
return this.query.innerJoin(table);
}
public IJoin leftJoin(String table) {
return this.query.leftJoin(table);
}
@Override
public IJoin rightJoin(String table) {
return this.query.rightJoin(table);
}
@Override
public IJoin fullJoin(String table) {
return this.query.fullJoin(table);
}
@Override
public Select where(String where) {
return this.query.where(where);
}
@Override
public Select where(String where, Object... execute) {
return this.query.where(where, execute);
}
@Override
public PreparedStatement executePrepare() throws SQLException {
return this.query.executePrepare();
}
@Override
public ResultSet execute() throws SQLException {
return this.executeQuery();
}
@Override
public Map<String, Object> fetch() throws SQLException {
return this.query.fetch();
}
@Override
public ResultSet fetchAll() throws SQLException {
return this.query.fetchAll();
}
@Override
public List<Map<String, Object>> fetchAllAsList() throws SQLException {
return this.query.fetchAllAsList();
}
@Override
public Boolean executeStatement() throws SQLException {
return this.query.executeStatement();
}
@Override
public ResultSet executeQuery() throws SQLException {
return this.query.executeQuery();
}
@Override
public int executeUpdate() throws SQLException {
return this.query.executeUpdate();
}
@Override
public String getPrefix() {
return "JOIN";
}
@Override
public Select getQuery() {
return query;
}
@Override
public String toQuery() {
StringBuilder query = new StringBuilder(this.getPrefix() + " " + this.table);
query.append(this.as != null ? " AS " + this.as : "");
query.append(this.on != null ? " ON (" + this.on + ")" : "");
query.append(this.using != null ? " USING (" + String.join(", ", this.using) + ")" : " ");
return query.toString();
}
@Override
public String toString() {
return this.toQuery();
}
}