Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*******************************************************************************************
* Copyright (c) 2016, zzg.zhou([email protected])
*
* Monalisa is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*******************************************************************************************/
package com.tsc9526.monalisa.orm;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import com.tsc9526.monalisa.orm.datasource.DBConfig;
import com.tsc9526.monalisa.orm.datasource.DbProp;
import com.tsc9526.monalisa.orm.dialect.Dialect;
import com.tsc9526.monalisa.orm.executor.BatchSqlExecutor;
import com.tsc9526.monalisa.orm.executor.BatchStatementExecutor;
import com.tsc9526.monalisa.orm.executor.CacheExecutor;
import com.tsc9526.monalisa.orm.executor.Execute;
import com.tsc9526.monalisa.orm.executor.ResultExecutor;
import com.tsc9526.monalisa.orm.executor.ResultHandler;
import com.tsc9526.monalisa.orm.executor.ResultLoadExecutor;
import com.tsc9526.monalisa.orm.executor.ResultSetExecutor;
import com.tsc9526.monalisa.orm.executor.ResultSetsExecutor;
import com.tsc9526.monalisa.orm.executor.UpdateExecutor;
import com.tsc9526.monalisa.orm.generator.DBExchange;
import com.tsc9526.monalisa.tools.agent.AgentClass;
import com.tsc9526.monalisa.tools.cache.Cache;
import com.tsc9526.monalisa.tools.cache.CacheKey;
import com.tsc9526.monalisa.tools.datatable.DataMap;
import com.tsc9526.monalisa.tools.datatable.DataTable;
import com.tsc9526.monalisa.tools.datatable.Page;
import com.tsc9526.monalisa.tools.io.MelpClose;
import com.tsc9526.monalisa.tools.logger.Logger;
import com.tsc9526.monalisa.tools.string.MelpSQL;
/**
* Database query, usage:
*
*
* @DB(url="jdbc:mysql://127.0.0.1:3306/test", username="root", password="root")
* public interface TestDB {
* public final static DBConfig DB=DBConfig.fromClass(TestDB.class)
* }
*
*
*
* Query q=new Query(TestDB.DB); //or: Query q=TestDB.DB.createQuery();
* q.add("select * from xxx where id=?",1);
* List<Result> r=q.getList(Result.class);
* Page<Result> p=q.getPage(Result.class,10,0);
* Result x=q.getResult(Result.class);
*
*
* @see com.tsc9526.monalisa.orm.annotation.DB
*
* @author zzg.zhou([email protected])
*/
@SuppressWarnings({"unchecked"})
public class Query {
static Logger logger=Logger.getLogger(Query.class.getName());
/**
* Create a database query dynamically
*
* @param theQueryClass Database query class which can be loaded dynamically.
* @param the class type
* @return create new instance.
*/
public static T create(Class theQueryClass){
return AgentClass.createAgent(theQueryClass);
}
/**
* Weather if show the running sql, default: false
*/
private Boolean debugSql=null;
protected StringBuilder sql = new StringBuilder();
protected List