package com.defonds.wms.module.common.dao;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.JdbcUpdateAffectedIncorrectNumberOfRowsException;
import org.springframework.orm.ibatis.SqlMapClientCallback;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import com.ibatis.sqlmap.client.SqlMapExecutor;
import com.ibatis.sqlmap.client.event.RowHandler;
import com.ibatis.sqlmap.engine.execution.BatchException;
import com.ibatis.sqlmap.engine.execution.BatchResult;
public class BaseDaoImpl extends SqlMapClientDaoSupport implements BaseDao {
public void test(){
//SqlMapClientTemplate ddd = super.getSqlMapClientTemplate();
}
private static final Log LOG = LogFactory.getLog(BaseDaoImpl.class);
@SuppressWarnings("unchecked")
public <T> T execute(SqlMapClientCallback action) throws DataAccessException {
return (T) getSqlMapClientTemplate().execute(action);
}
@SuppressWarnings("unchecked")
public <T> T queryForObject(String statementName) throws DataAccessException {
return (T) getSqlMapClientTemplate().queryForObject(statementName);
}
@SuppressWarnings("unchecked")
public <T> T queryForObject(final String statementName, final Object parameterObject) throws DataAccessException {
return (T) getSqlMapClientTemplate().queryForObject(statementName, parameterObject);
}
@SuppressWarnings("unchecked")
public <T> T queryForObject(final String statementName, final Object parameterObject, final Object resultObject) throws DataAccessException {
return (T) getSqlMapClientTemplate().queryForObject(statementName, parameterObject, resultObject);
}
public List<?> queryForList(String statementName) throws DataAccessException {
return queryForList(statementName, null);
}
public List<?> queryForList(final String statementName, final Object parameterObject) throws DataAccessException {
return getSqlMapClientTemplate().queryForList(statementName, parameterObject);
}
public List<?> queryForList(String statementName, int skipResults, int maxResults)throws DataAccessException {
return queryForList(statementName, null, skipResults, maxResults);
}
public List<?> queryForList(final String statementName, final Object parameterObject, final int skipResults, final int maxResults) throws DataAccessException {
return getSqlMapClientTemplate().queryForList(statementName, parameterObject, skipResults, maxResults);
}
public void queryWithRowHandler(String statementName, RowHandler rowHandler)throws DataAccessException {
queryWithRowHandler(statementName, null, rowHandler);
}
public void queryWithRowHandler( final String statementName, final Object parameterObject, final RowHandler rowHandler) throws DataAccessException {
getSqlMapClientTemplate().queryWithRowHandler(statementName, parameterObject, rowHandler);
}
public Map<?,?> queryForMap( final String statementName, final Object parameterObject, final String keyProperty) throws DataAccessException {
return getSqlMapClientTemplate().queryForMap(statementName, parameterObject, keyProperty);
}
public Map<?,?> queryForMap( final String statementName, final Object parameterObject, final String keyProperty, final String valueProperty) throws DataAccessException {
return getSqlMapClientTemplate().queryForMap(statementName, parameterObject, keyProperty, valueProperty);
}
public <T> T insert(String statementName) throws DataAccessException {
return (T) getSqlMapClientTemplate().insert(statementName, null);
}
@SuppressWarnings("unchecked")
public <T> T insert(final String statementName, final Object parameterObject) throws DataAccessException {
return (T) getSqlMapClientTemplate().insert(statementName, parameterObject);
}
public int update(String statementName) throws DataAccessException {
return update(statementName, null);
}
public int update(final String statementName, final Object parameterObject) throws DataAccessException {
Integer result = (Integer) execute(new SqlMapClientCallback() {
public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
return new Integer(executor.update(statementName, parameterObject));
}
});
return result.intValue();
}
public void update(String statementName, Object parameterObject, int requiredRowsAffected)
throws DataAccessException {
int actualRowsAffected = update(statementName, parameterObject);
if (actualRowsAffected != requiredRowsAffected) {
throw new JdbcUpdateAffectedIncorrectNumberOfRowsException(
statementName, requiredRowsAffected, actualRowsAffected);
}
}
public int delete(String statementName) throws DataAccessException {
return delete(statementName, null);
}
public int delete(final String statementName, final Object parameterObject)
throws DataAccessException {
Integer result = (Integer) execute(new SqlMapClientCallback() {
public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
return new Integer(executor.delete(statementName, parameterObject));
}
});
return result.intValue();
}
public void delete(String statementName, Object parameterObject, int requiredRowsAffected) throws DataAccessException {
int actualRowsAffected = delete(statementName, parameterObject);
if (actualRowsAffected != requiredRowsAffected) {
throw new JdbcUpdateAffectedIncorrectNumberOfRowsException(
statementName, requiredRowsAffected, actualRowsAffected);
}
}
public <T> int updateBatch(final String statementName, final List<T> list) {
if(list == null || list.isEmpty()){
return 0;
}
SqlMapClientCallback callback = new SqlMapClientCallback() {
public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
executor.startBatch();
for (Object obj : list) {
executor.update(statementName, obj);
}
try {
return executor.executeBatchDetailed();
} catch (BatchException e) {
LOG.error(e.getMessage(), e);
throw new SQLException("Batch update failed!");
}
}
};
List<BatchResult> retList = (List<BatchResult>) getSqlMapClientTemplate().execute(callback);
return batchResult(retList);
}
/**
* 从批处理结果返回处理成功的记录数
* @param batchResultList
* @return count
*/
private int batchResult(List<BatchResult> batchResultList) {
int count = 0;
if (batchResultList != null && !batchResultList.isEmpty()) {
BatchResult result = batchResultList.get(0);
if (result != null) {
for (int i : result.getUpdateCounts()) {
if (i == java.sql.Statement.SUCCESS_NO_INFO) {
count++;
} else {
count += i;
}
}
}
}
return count;
}
public <T> void insertBatch(final String statementName, final List<T> list) {
getSqlMapClientTemplate().execute(
new SqlMapClientCallback() {
public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
executor.startBatch();
for (int i = 0; i < list.size(); i++) {
T t = (T)list.get(i);
executor.insert(statementName, t);
if (i%50 == 0) {
executor.executeBatch();
}
}
executor.executeBatch();
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本资源是一个 Wowza 支持 RESTful web 服务的一个简单的 demo。关于如何让 wowza 能够支持 RESTful api 的步骤请参考博客《让你的 wowza 服务器提供 RESTful web 服务》,地址是:http://blog.csdn.net/defonds/article/details/30490271。
资源推荐
资源详情
资源评论
收起资源包目录
defonds-server-module.zip (68个子文件)
defonds-server-module
pom.xml 10KB
target
test-classes
dep-libs
spring-beans-3.1.2.RELEASE.jar 578KB
spring-context-support-3.1.2.RELEASE.jar 105KB
ezmorph-1.0.6.jar 84KB
mysql-connector-java-5.1.19.jar 783KB
commons-collections-3.2.1.jar 562KB
log4j-1.2.16.jar 470KB
aopalliance-1.0.jar 4KB
commons-beanutils-1.8.3.jar 227KB
spring-jdbc-3.1.2.RELEASE.jar 395KB
commons-httpclient-3.1.jar 298KB
spring-asm-3.1.2.RELEASE.jar 52KB
commons-logging-1.1.1.jar 59KB
spring-context-3.1.2.RELEASE.jar 813KB
ibatis-sqlmap-2.3.4.726.jar 375KB
commons-lang-2.6.jar 278KB
commons-dbcp-1.4.jar 157KB
slf4j-api-1.6.6.jar 26KB
slf4j-log4j12-1.6.6.jar 9KB
spring-expression-3.1.2.RELEASE.jar 172KB
commons-codec-1.6.jar 227KB
spring-core-3.1.2.RELEASE.jar 439KB
json-lib-2.4-jdk15.jar 155KB
spring-tx-3.1.2.RELEASE.jar 239KB
spring-aop-3.1.2.RELEASE.jar 325KB
commons-pool-1.6.jar 109KB
spring-orm-3.1.2.RELEASE.jar 371KB
defonds-server-module.jar 18KB
classes
com
defonds
wms
module
server
ServerMonitorHttpInterface.class 2KB
DefondsWowzaServerListener.class 3KB
test
service
TestServiceImpl.class 2KB
TestService.class 160B
entity
Config.class 2KB
common
dao
BaseDao.class 3KB
BaseDaoImpl$2.class 1KB
BaseDaoImpl$1.class 1KB
BaseDaoImpl.class 7KB
BaseDaoImpl$4.class 2KB
BaseDaoImpl$3.class 2KB
service
BaseService.class 668B
utils
spring
ApplicationContextUtils.class 862B
sqlMapConfig.xml 394B
config.xml 723B
config.properties 77B
spring-context.xml 3KB
.settings
org.eclipse.core.resources.prefs 88B
org.maven.ide.eclipse.prefs 249B
org.eclipse.jdt.core.prefs 695B
src
test
java
main
java
com
defonds
wms
module
server
DefondsWowzaServerListener.java 2KB
ServerMonitorHttpInterface.java 1KB
test
service
TestService.java 105B
TestServiceImpl.java 855B
entity
Config.java 2KB
common
dao
BaseDao.java 3KB
BaseDaoImpl.java 8KB
service
BaseService.java 295B
utils
spring
ApplicationContextUtils.java 572B
sqlMapConfig.xml 394B
config.xml 723B
config.properties 77B
spring-context.xml 3KB
.project 575B
.classpath 512B
lib
wms-server.jar 5.43MB
wms-stream-publish.jar 33KB
wms-httpstreamer-cupertinostreaming.jar 296KB
wms-httpstreamer-smoothstreaming.jar 214KB
wms-httpstreamer-directstreaming.jar 8KB
共 68 条
- 1
资源评论
- songdaisd2016-06-23有没有不是maven开发的啊
Defonds
- 粉丝: 7094
- 资源: 426
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 129335283047061xiazaigongjuxiang(去重软件).apk
- Android环境检测工具,检测ksu,lsp,magisk等
- WordPress后台美化插件QuarterAdmin分享
- PCB_Project单片机绘制 (2024-5-11 22-22-13).zip
- nccl-local-repo-ubuntu2204-2.21.5-cuda12.4-1.0-1-amd64
- STM32移植LVGL源码工程 stm32移植GUI-Guider源码 LVGL移植源码
- Screenshot_20240522_084328_com.tencent.mm.jpg
- 附件计算机专业课选课说明-1.xlsx
- 基于TypeScript的ahousepet-admin-web管理系统设计源码
- 《广东开放大学学习指引》期末考核要求0522.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功