com.bixuebihui.db.SimpleStatement Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of c-dbtools Show documentation
Show all versions of c-dbtools Show documentation
a fast small database connection pool and a active record flavor mini framework
package com.bixuebihui.db;
import java.sql.SQLException;
import java.util.List;
/**
* Date: 13-4-18
* Time: 下午6:04
* 简单的数据库查询
* @author xingwx
* @version $Id: $Id
*/
public interface SimpleStatement {
/**
* insert.
* 插入单个
* @param entity a T object.
* @return a boolean.
* @throws java.sql.SQLException if any.
*/
boolean insert(T entity)throws SQLException;
/**
* insertAndReferences.
* 插入并插入依赖
* @param entity a T object.
* @return a boolean.
* @throws java.sql.SQLException if any.
*/
boolean insertAndReferences(T entity)throws SQLException;
//插入多个
/**
* insert.
*
* @param entities a {@link java.util.List} object.
* @return a boolean.
* @throws java.sql.SQLException if any.
*/
boolean insert(List entities)throws SQLException;
//插入或更新
/**
* insertOrUpdate.
*
* @param entity a T object.
* @return a boolean.
* @throws java.sql.SQLException if any.
*/
boolean insertOrUpdate(T entity) throws SQLException;
//插入或更新多个
/**
* insertOrUpdate.
*
* @param entity a {@link java.util.List} object.
* @return a boolean.
* @throws java.sql.SQLException if any.
*/
boolean insertOrUpdate(List entity)throws SQLException;
//通过主键获得
/**
* findByKey.
*
* @param id a V object.
* @return a T object.
* @throws java.sql.SQLException if any.
*/
T findByKey(V id)throws SQLException;
//通过多个主键获得
/**
* findAllByKeys.
*
* @param id an array of V[] objects.
* @return a {@link java.util.List} object.
* @throws java.sql.SQLException if any.
*/
List findAllByKeys(V[] id)throws SQLException;
//更新
/**
* update.
*
* @param entity a T object.
* @return a boolean.
* @throws java.sql.SQLException if any.
*/
boolean update(T entity) throws SQLException;
/**
* updateAndReferences.
* 更新并更新依赖
* @param entity a T object.
* @return a boolean.
* @throws java.sql.SQLException if any.
*/
boolean updateAndReferences(T entity)throws SQLException;
/**
* update.
* 批量更新
* @param entities a {@link java.util.List} object.
* @return a boolean.
* @throws java.sql.SQLException if any.
*/
boolean update(List entities)throws SQLException;
/**
* delete.
* 删除单个
* @param entity a T object.
* @return a boolean.
* @throws java.sql.SQLException if any.
*/
boolean delete(T entity)throws SQLException;
/**
* deleteByKey.
* 删除单个
* @param id a V object.
* @return a boolean.
* @throws java.sql.SQLException if any.
*/
boolean deleteByKey(V id)throws SQLException;
//批量删除
/**
* deleteByKeys.
*
* @param id an array of V[] objects.
* @return a boolean.
* @throws java.sql.SQLException if any.
*/
boolean deleteByKeys(V[] id)throws SQLException;
//获得所有
/**
* findAll.
*
* @return a {@link java.util.List} object.
* @throws java.lang.IllegalAccessException if any.
* @throws java.sql.SQLException if any.
* @throws java.lang.InstantiationException if any.
*/
List findAll() throws IllegalAccessException, SQLException, InstantiationException;
//获得总数
/**
* countAll.
*
* @return a int.
* @throws java.sql.SQLException if any.
*/
int countAll() throws SQLException;
}