com.objectsql.query.QueryImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of object-sql Show documentation
Show all versions of object-sql Show documentation
Lightweight Object SQL Relational Mapping (OSRM)
The newest version!
/*
* Copyright 2017 @objectsql.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.objectsql.query;
import com.objectsql.spring.SpringUtils;
import com.objectsql.support.*;
import com.objectsql.annotation.RdTable;
import com.objectsql.utils.ORMUtils;
import java.util.*;
public class QueryImpl extends AbstractQueryImpl implements Query {
private Class> table;
private Class> returnClass;
private List returnColumns = new ArrayList();
private List fixedReturnColumns = new ArrayList();
private List groups = new ArrayList();
private List groupCountsSelectColumns = new ArrayList();
public Query orderDesc(String name){
orders.add(new Order(new Column(name), Order.DESC));
return this;
}
public Query whereIsNull(String name){
addCondition(new Condition().and(new Expression(new Column(name), ExpressionType.CDT_IS_NULL)));
return this;
}
public Query whereIsNotNull(String name){
addCondition(new Condition().and(new Expression(new Column(name), ExpressionType.CDT_IS_NOT_NULL)));
return this;
}
public Query whereIsEmpty(String name){
addCondition(new Condition().and(new Expression(new Column(name), ExpressionType.CDT_IS_EMPTY)));
return this;
}
public Query whereIsNotEmpty(String name){
addCondition(new Condition().and(new Expression(new Column(name), ExpressionType.CDT_IS_NOT_EMPTY)));
return this;
}
@Override
public Query where(LambdaQuery fieldFunction, ExpressionType type){
return where(fieldFunction.getColumnName(), type);
}
@Override
public Query where(String name, ExpressionType type){
if(ExpressionType.CDT_IS_NULL == type
|| ExpressionType.CDT_IS_NOT_NULL == type
|| ExpressionType.CDT_IS_EMPTY == type
|| ExpressionType.CDT_IS_NOT_EMPTY == type
) {
addCondition(new Condition().and(new Expression(new Column(name), type)));
}
return this;
}
@Override
public Query whereEqual(LambdaQuery fieldFunction, Object value){
return whereEqual(fieldFunction.getColumnName(), value);
}
@Override
public Query whereEqual(String name, Object value) {
return where(name, value, ExpressionType.CDT_EQUAL);
}
@Override
public Query whereNotEqual(LambdaQuery fieldFunction, Object value){
return whereNotEqual(fieldFunction.getColumnName(), value);
}
@Override
public Query whereNotEqual(String name, Object value) {
return where(name, value, ExpressionType.CDT_NOT_EQUAL);
}
@Override
public Query whereLike(String name, String value) {
return where(name, value, ExpressionType.CDT_LIKE);
}
@Override
public Query whereNotLike(String name, String value) {
return where(name, value, ExpressionType.CDT_NOT_LIKE);
}
@Override
public Query whereStartWith(String name, String value) {
return where(name, value, ExpressionType.CDT_START_WITH);
}
@Override
public Query whereEndWith(String name, String value) {
return where(name, value, ExpressionType.CDT_END_WITH);
}
@Override
public Query whereNotStartWith(String name, String value) {
return where(name, value, ExpressionType.CDT_NOT_START_WITH);
}
@Override
public Query whereNotEndWith(String name, String value) {
return where(name, value, ExpressionType.CDT_NOT_END_WITH);
}
@Override
public Query whereLike(LambdaQuery fieldFunction, String value){
return whereLike(fieldFunction.getColumnName(), value);
}
@Override
public Query whereNotLike(LambdaQuery fieldFunction, String value){
return whereNotLike(fieldFunction.getColumnName(), value);
}
@Override
public Query whereStartWith(LambdaQuery fieldFunction, String value){
return whereStartWith(fieldFunction.getColumnName(), value);
}
@Override
public Query whereEndWith(LambdaQuery fieldFunction, String value){
return whereEndWith(fieldFunction.getColumnName(), value);
}
@Override
public Query whereNotStartWith(LambdaQuery fieldFunction, String value){
return whereNotStartWith(fieldFunction.getColumnName(), value);
}
@Override
public Query whereNotEndWith(LambdaQuery fieldFunction, String value){
return whereNotEndWith(fieldFunction.getColumnName(), value);
}
@Override
public Query whereLess(String name, Object value) {
return where(name, value, ExpressionType.CDT_LESS);
}
@Override
public Query whereLessEqual(String name, Object value) {
return where(name, value, ExpressionType.CDT_LESS_EQUAL);
}
@Override
public Query whereMore(String name, Object value) {
return where(name, value, ExpressionType.CDT_MORE);
}
@Override
public Query whereMoreEqual(String name, Object value) {
return where(name, value, ExpressionType.CDT_MORE_EQUAL);
}
@Override
public Query whereLess(LambdaQuery fieldFunction, Object value){
return whereLess(fieldFunction.getColumnName(), value);
}
@Override
public Query whereLessEqual(LambdaQuery fieldFunction, Object value){
return whereLessEqual(fieldFunction.getColumnName(), value);
}
@Override
public Query whereMore(LambdaQuery fieldFunction, Object value){
return whereMore(fieldFunction.getColumnName(), value);
}
@Override
public Query whereMoreEqual(LambdaQuery fieldFunction, Object value){
return whereMoreEqual(fieldFunction.getColumnName(), value);
}
@Override
public Query whereIn(String name, Collection value) {
return where(name, value, ExpressionType.CDT_IN);
}
@Override
public Query whereNotIn(String name, Collection value) {
return where(name, value, ExpressionType.CDT_NOT_IN);
}
@Override
public Query whereInValues(String name, Object... values) {
List