All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jquicker.persistent.rdb.model.FinalSQL Maven / Gradle / Ivy

There is a newer version: 1.1.0
Show newest version
package com.jquicker.persistent.rdb.model;

import java.util.ArrayList;
import java.util.List;

import com.jquicker.commons.util.JsonUtils;

/**
 * 不带命名参数发及动态表达式的SQL语句
* 参数用?占位 * @author OL */ public class FinalSQL { private String sql; private Object[] params = {}; private Object[][] batchParams = {}; private String countSql; private int offset = 0; private int size = 10; private List list = new ArrayList(); private List batch = new ArrayList(); public void addParam(Object value) { list.add(value); } public void addBatchParam(Object[] values) { batch.add(values); } public String getSql() { return sql; } public void setSql(String sql) { this.sql = sql; } public Object[] getParams() { if (params != null && params.length == 0) { if (!list.isEmpty()) { params = list.toArray(); } } return params; } public void setParams(Object[] params) { this.params = params; } public Object[][] getBatchParams() { if (batchParams != null && batchParams.length == 0) { if (!batch.isEmpty()) { batchParams = batch.toArray(new Object[0][0]); } } return batchParams; } public void setBatchParams(Object[][] batchParams) { this.batchParams = batchParams; } public String getCountSql() { return countSql; } public void setCountSql(String countSql) { this.countSql = countSql; } public int getOffset() { return offset; } public void setOffset(int offset) { this.offset = offset; } public int getSize() { return size; } public void setSize(int size) { this.size = size; } @Override public String toString() { return JsonUtils.toJsonString(this); } }