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 the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to you 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.
*
* =================================================================================================
*
* This software consists of voluntary contributions made by many individuals on behalf of the
* Apache Software Foundation. For more information on the Apache Software Foundation, please see
* .
*
* +------------------------------------------------------------------------------------------------+
* | License: http://www.apache.org/licenses/LICENSE-2.0.txt |
* | Author: Yong.Teng |
* | Copyright @ 2013-2022 Buession.com Inc. |
* +------------------------------------------------------------------------------------------------+
*/
package com.buession.dao;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import com.buession.beans.BeanUtils;
import com.buession.core.utils.FieldUtils;
import com.buession.core.utils.Assert;
import com.buession.core.utils.RandomUtils;
import com.buession.core.validator.Validate;
import com.buession.lang.Order;
import org.apache.ibatis.mapping.ResultMap;
import org.apache.ibatis.mapping.ResultMapping;
import org.apache.ibatis.session.RowBounds;
import org.mybatis.spring.SqlSessionTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.buession.core.Pagination;
import com.buession.core.exception.OperationException;
/**
* MyBatis Data Access Object 抽象类
*
* @param
* 注解类型
* @param
* 实体类
*
* @author Yong.Teng
*/
public abstract class AbstractMyBatisDao
extends AbstractDao
implements MyBatisDao
{
/**
* master SqlSessionTemplate
*/
@Resource
protected SqlSessionTemplate masterSqlSessionTemplate;
/**
* slave SqlSessionTemplate
*/
@Resource
protected List slaveSqlSessionTemplates;
private final static Logger logger = LoggerFactory.getLogger(AbstractMyBatisDao.class);
/**
* 返回 master SqlSessionTemplate
*
* @return master SqlSessionTemplate
*/
public SqlSessionTemplate getMasterSqlSessionTemplate(){
return masterSqlSessionTemplate;
}
/**
* 设置 master SqlSessionTemplate
*
* @param masterSqlSessionTemplate
* master SqlSessionTemplate
*/
public void setMasterSqlSessionTemplate(final SqlSessionTemplate masterSqlSessionTemplate){
this.masterSqlSessionTemplate = masterSqlSessionTemplate;
}
/**
* 返回 slave SqlSessionTemplate
*
* @return slave SqlSessionTemplate
*/
public List getSlaveSqlSessionTemplates(){
return slaveSqlSessionTemplates;
}
/**
* 设置 slave SqlSessionTemplate
*
* @param slaveSqlSessionTemplates
* slave SqlSessionTemplate
*/
public void setSlaveSqlSessionTemplates(final List slaveSqlSessionTemplates){
this.slaveSqlSessionTemplates = slaveSqlSessionTemplates;
}
@Override
public int insert(E e){
return getMasterSqlSessionTemplate().insert(getStatement(DML.INSERT), e);
}
@Override
public int replace(E e){
return getMasterSqlSessionTemplate().insert(getStatement(DML.REPLACE), e);
}
@Override
@SuppressWarnings("unchecked")
public int update(E e, Map conditions){
Assert.isNull(e, "The data could not be empty for update.");
Map data = new HashMap<>(conditions == null ? 16 : conditions.size());
if(conditions != null){
data.putAll(conditions);
}
Map