tech.ydb.jdbc.query.QueryStatement Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ydb-jdbc-driver Show documentation
Show all versions of ydb-jdbc-driver Show documentation
JDBC Driver over YDB Java SDK
package tech.ydb.jdbc.query;
import java.util.ArrayList;
import java.util.List;
import tech.ydb.jdbc.common.TypeDescription;
/**
*
* @author Aleksandr Gorshenin
*/
public class QueryStatement {
private final QueryType queryType;
private final QueryCmd command;
private final List parameters = new ArrayList<>();
private boolean hasReturinng = false;
public QueryStatement(QueryType type, QueryCmd command) {
this.queryType = type;
this.command = command;
}
public QueryType getType() {
return queryType;
}
public List getParams() {
return parameters;
}
public void addParameter(String name, TypeDescription type) {
this.parameters.add(new ParamDescription(name, type));
}
public void setHasReturning(boolean hasReturning) {
this.hasReturinng = hasReturning;
}
public boolean hasUpdateCount() {
return (command == QueryCmd.INSERT_UPSERT || command == QueryCmd.UPDATE_REPLACE_DELETE) && !hasReturinng;
}
public boolean hasResults() {
return command == QueryCmd.SELECT || hasReturinng;
}
public boolean isDDL() {
return command == QueryCmd.CREATE_ALTER_DROP;
}
}