
org.jiucheng.plugin.db.BaseDaoImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jiucheng Show documentation
Show all versions of jiucheng Show documentation
jiucheng is a java speed development of lightweight framework.
The newest version!
package org.jiucheng.plugin.db;
import java.io.Serializable;
import java.sql.Connection;
import java.sql.ResultSet;
import java.util.List;
import java.util.Map;
import org.jiucheng.ioc.annotation.Impl;
import org.jiucheng.ioc.annotation.Repository;
import org.jiucheng.orm.SQLHelper;
import org.jiucheng.orm.dialect.Dialect;
import org.jiucheng.orm.dialect.impl.MySQLDialect;
import org.jiucheng.orm.support.DruidDataSourceBuilder;
import org.jiucheng.orm.util.EntityUtil;
import org.jiucheng.orm.util.JdbcUtil;
@Repository("baseDao")
public class BaseDaoImpl implements IBaseDao {
@Impl(MySQLDialect.class)
private Dialect dialect;
@Impl(DruidDataSourceBuilder.class)
private DruidDataSourceBuilder druidDataSourceBuilder;
public Serializable save(T entity) {
return EntityUtil.save(getDialect(), getConn(), entity);
}
public Serializable saveOrUpdate(T entity) {
return EntityUtil.saveOrUpdate(getDialect(), getConn(), entity);
}
public boolean update(T entity) {
return EntityUtil.update(getDialect(), getConn(), entity);
}
public int delete(T entity) {
return EntityUtil.delete(getDialect(), getConn(), entity);
}
public List list(T entity) {
return EntityUtil.list(getDialect(), getConn(), entity);
}
private Dialect getDialect() {
return dialect;
}
public Connection getConn() {
return druidDataSourceBuilder.getConn();
}
public Serializable saveBySQL(SQLHelper sh) {
return JdbcUtil.save(getConn(), sh);
}
public boolean updateBySQL(SQLHelper sh) {
if(JdbcUtil.update(getConn(), sh) > 0 ) {
return true;
}
return false;
}
public boolean deleteBySQL(SQLHelper sh) {
if(JdbcUtil.delete(getConn(), sh) > 0) {
return true;
}
return false;
}
@SuppressWarnings("rawtypes")
public List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy