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.
/**
* Licensed to JumpMind Inc under one or more contributor
* license agreements. See the NOTICE file distributed
* with this work for additional information regarding
* copyright ownership. JumpMind Inc licenses this file
* to you under the GNU General Public License, version 3.0 (GPLv3)
* (the "License"); you may not use this file except in compliance
* with the License.
*
* You should have received a copy of the GNU General Public License,
* version 3.0 (GPLv3) along with this library; if not, see
* .
*
* 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 org.jumpmind.db.sql;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
abstract public class AbstractSqlTemplate implements ISqlTemplate {
protected final static Logger log = LoggerFactory.getLogger(AbstractSqlTemplate.class
.getPackage().getName());
protected boolean dateOverrideToTimestamp;
protected String identifierQuoteString;
protected void logSql(String sql, Object[] args) {
if (log.isDebugEnabled()) {
log.debug(sql);
if (args != null && args.length > 0) {
log.debug("sql args: {}", Arrays.toString(args));
}
}
}
public T queryForObject(String sql, ISqlRowMapper mapper, Object... args) {
List list = query(sql, mapper, args);
if (list != null && list.size() > 0) {
return list.get(0);
} else {
return null;
}
}
public String queryForString(String sql, Object... args) {
return queryForObject(sql, String.class, args);
}
public int queryForInt(String sql, Map params) {
ParsedSql parsedSql = NamedParameterUtils.parseSqlStatement(sql);
String newSql = NamedParameterUtils.substituteNamedParameters(parsedSql, params);
Object[] args = NamedParameterUtils.buildValueArray(parsedSql, params);
return queryForInt(newSql, args);
}
public int queryForInt(String sql, Object... args) {
Integer number = queryForObject(sql, Integer.class, args);
if (number != null) {
return number.intValue();
} else {
return 0;
}
}
public long queryForLong(String sql, Object... args) {
Long number = queryForObject(sql, Long.class, args);
if (number != null) {
return number.longValue();
} else {
return 0l;
}
}
public Map queryForMap(String sql, final String keyColumn,
final String valueColumn, Object... args) {
final Map map = new HashMap();
query(sql, new ISqlRowMapper