24 Star 34 Fork 18

codefinger / codefinger-dao

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

#codefinger-dao

#简介

数据库访问工具,功能强大、简洁、高效、零配置,支持MySQL、SQLServer、Oracle。

#特性(完整Demo,请看org.codefinger.test.DaoUtilDemo)

###1.语法分析,智能展开、拼接SQL语句

// 前面这里采用阿里巴巴的数据库连接池,主要是为了演示执行的SQL语句(您可以采用其它数据连接池)
DruidDataSource dataSource = new DruidDataSource();
Log4jFilter log4jFilter = new Log4jFilter();
log4jFilter.setResultSetLogEnabled(false);
log4jFilter.setStatementLogEnabled(false);
log4jFilter.setStatementExecutableSqlLogEnable(true);
Filter filter = log4jFilter;
dataSource.setProxyFilters(Arrays.asList(filter));

// 这里采用MySQL进行演示,您也可以选择SQLServer或Oracle
dataSource.setUrl("jdbc:mysql://192.168.189.135:3306/codefinger?useUnicode=true&characterEncoding=utf-8");
dataSource.setUsername("root");
dataSource.setPassword("root");

// 1.这里是真正开始,创建数据库工具
DaoUtil daoUtil = new DaoUtil();
daoUtil.setDataSource(dataSource);

// 2.然后您就可以创建查询对象了
Query query = daoUtil.createQuery("select * from customer where f_name left like :name and f_age > :age");

// 3.进行查询
query.putParam("name", "张三").getMapList();
/*
 * 这时,工具自动进行了如下查询(只用了其中一个查询条件):
 * 
 * SELECT 
 * 		CUSTOMER.F_ID, 
 * 		CUSTOMER.F_NAME, 
 * 		CUSTOMER.F_AGE,
 * 		CUSTOMER.F_MONEY 
 * FROM 
 * 		CUSTOMER 
 * WHERE 
 * 		F_NAME LIKE '张三%'
 */

query.putParam("age", 15).getMapList();
/*
 * 这时,工具自动进行了如下查询(这次用了另一个查询条件):
 * 
 * SELECT 
 * 		CUSTOMER.F_ID, 
 * 		CUSTOMER.F_NAME, 
 * 		CUSTOMER.F_AGE,
 * 		CUSTOMER.F_MONEY 
 * FROM 
 * 		CUSTOMER 
 * WHERE 
 * 		F_AGE > 15
 */

query.putParam("name", "张三").putParam("age", 15).getMapList();
/*
 * 这时,工具自动进行了如下查询(这次两个查询条件都同时利用了):
 * 
 * SELECT 
 * 		CUSTOMER.F_ID, 
 * 		CUSTOMER.F_NAME, 
 * 		CUSTOMER.F_AGE,
 * 		CUSTOMER.F_MONEY 
 * FROM 
 * 		CUSTOMER 
 * WHERE 
 * 		F_NAME LIKE '张三%' 
 * 		AND F_AGE > 15
 */

// 4.您可以试试更复杂的查询条件
query = daoUtil.createQuery("select * from customer where f_name left like :name and (f_age >= :minAge or f_age <= :maxAge) order by f_age,f_name desc");

query.putParam("minAge", 15)// 只根据最小年龄进行筛选
		.setOrders(0)// 只根据年龄进行排序
		.getMapList();
/*
 * 这时,工具自动进行了如下查询(是不是很智能):
 * 
 * SELECT 
 * 		CUSTOMER.F_ID, 
 * 		CUSTOMER.F_NAME, 
 * 		CUSTOMER.F_AGE,
 * 		CUSTOMER.F_MONEY 
 * FROM 
 * 		CUSTOMER 
 * WHERE 
 * 		F_AGE >= 15 
 * ORDER BY 
 * 		F_AGE ASC
 */

###2.支持命名参数和顺序参数

// 刚才上面的掩饰采用的就是命名参数,这里采用顺序参数
query = daoUtil.createQuery("select * from customer where f_name all like ? and (f_age >= ? or f_age <= ?) order by f_age,f_name desc");

query.setParams("张三", null, 20)// 只根据姓名和最大年龄进行筛选
		.setOrders(1)// 只根据姓名进行排序
		.getMapList();
/*
 * 这时,工具自动进行了如下查询(真的很智能!):
 * 
 * SELECT 
 * 		CUSTOMER.F_ID, 
 * 		CUSTOMER.F_NAME, 
 * 		CUSTOMER.F_AGE,
 * 		CUSTOMER.F_MONEY 
 * FROM 
 * 		CUSTOMER 
 * WHERE 
 * 		F_NAME LIKE '%张三%' 
 * 		AND F_AGE <= 20 
 * ORDER BY 
 * 		F_NAME DESC
 */

###3.支持复杂的查询(左、内连接查询、子查询、Union、各种条件表达式like、in、exists、any、all等)

// @formatter:off
// 刚才上面的SQL语句还是太简单了,来点复杂的看看
query = daoUtil.createQuery(
		"select " + 
				"A.f_id id," + 
				"B.f_name as name," + 
				"C.f_age age," + 
				"D.f_money as money " + 
		"from " + 
				"customer A " + 
				"inner join customer B on B.f_id = A.f_id " + 
				"left join customer C on C.f_id = B.f_id " + 
				"inner join customer D on D.f_id = C.f_id " + 
		"where " + 
				"(A.f_age >= :minAge or A.f_age <= :minAge) " + 
				"and B.f_name left like :leftName " + 
				"and C.f_name all like :allName " + 
				"and D.f_money not in (3.5,3.6,:moneyNotIn) " + 
				"and D.f_age is not null " + 
				"and D.f_age = (select f_age from customer where f_age != :notAge) " + 
		"group by " + 
				"A.*,B.*,C.*,D.* " + 
		"having " + 
				"AVG(D.f_money) > 1000 " + 
		"union all " + 
				"select " + 
					"f_id id," + 
					"f_name name," + 
					"f_age as age," + 
					"f_money money " + 
				"from customer " + 
		"order by " + 
				"money desc,age asc");
// @formatter:on

query.putParam("notAge", 25) // 年龄不等于25
		.putParam("moneyNotIn", Arrays.asList(3.7, 9.125, 10000.9)) // Money不包含列表中的值
		.putParam("allName", "王") // 模糊查询,姓名中包含‘王’的
		.putParam("minAge", 10)// 最小年龄
		.setOrders(0) // 只按照Money排序
		.getMapSet();

/*
 * 就算是这么复杂的SQL语句,也能够被智能分析出来:
 * 
 * SELECT
 * 		A.F_ID AS ID,
 * 		B.F_NAME AS NAME, 
 * 		C.F_AGE AS AGE, 
 * 		D.F_MONEY AS MONEY 
 * FROM 
 * 		CUSTOMER A 
 * INNER JOIN CUSTOMER B ON B.F_ID = A.F_ID 
 * LEFT JOIN CUSTOMER C ON C.F_ID = B.F_ID 
 * INNER JOIN CUSTOMER D ON D.F_ID = C.F_ID 
 * WHERE 
 * 		(A.F_AGE >= 10 OR A.F_AGE <= 10) 
 * 		AND C.F_NAME LIKE '%王%'
 * 		AND D.F_MONEY NOT IN (3.5, 3.6, 3.7, 9.125, 10000.9) 
 * 		AND D.F_AGE IS NOT NULL 
 * 		AND D.F_AGE = (SELECT F_AGE FROM CUSTOMER WHERE F_AGE != 25)
 * GROUP BY 
 * 		A.F_ID, A.F_NAME, A.F_AGE, A.F_MONEY, B.F_ID, B.F_NAME,
 * 		B.F_AGE, B.F_MONEY, C.F_ID, C.F_NAME, C.F_AGE, C.F_MONEY, D.F_ID,
 * 		D.F_NAME, D.F_AGE, D.F_MONEY 
 * HAVING 
 * 		AVG(DISTINCT D.F_MONEY) > 1000
 * UNION ALL 
 * 		SELECT 
 * 			F_ID AS ID,
 * 			F_NAME AS NAME, 
 * 			F_AGE AS AGE, 
 * 			F_MONEY AS MONEY 
 * 		FROM CUSTOMER 
 * ORDER BY 
 * 		MONEY DESC
 */

###4.支持总量(Count)和分页查询(总量查询能够查询出本次查询结果(不分页)的总记录数)

// 让我们看看查询Count和分页有多简单
QueryChain queryChain = query.putParam("notAge", 25) // 年龄不等于25
		.putParam("moneyNotIn", Arrays.asList(3.7, 9.125, 10000.9)) // Money不包含列表中的值
		.putParam("allName", "王") // 模糊查询,姓名中包含‘王’的
		.putParam("minAge", 10)// 最小年龄
		.setOrders(0) // 只按照Money排序
		.setPage(5, 10); // 查第5页,每页显示10条
// Count查询

queryChain.queryCount();
/*
 * SELECT 
 * 		COUNT(1) 
 * FROM 
 * 	(
 * 		SELECT 
 * 			A.F_ID AS ID, 
 * 			B.F_NAME AS NAME, 
 * 			C.F_AGE AS AGE, 
 * 			D.F_MONEY AS MONEY 
 * 		FROM 
 * 			CUSTOMER A 
 * 		INNER JOIN CUSTOMER B ON B.F_ID = A.F_ID 
 * 		LEFT JOIN CUSTOMER C ON C.F_ID = B.F_ID 
 * 		INNER JOIN CUSTOMER D ON D.F_ID = C.F_ID 
 * 		WHERE 
 * 			(A.F_AGE >= 10 OR A.F_AGE <= 10) 
 * 			AND C.F_NAME LIKE '%王%'
 * 			AND D.F_MONEY NOT IN (3.5, 3.6, 3.7, 9.125, 10000.9) 
 * 			AND D.F_AGE IS NOT NULL 
 * 			AND D.F_AGE = (SELECT F_AGE FROM CUSTOMER WHERE F_AGE != 25)
 * 		GROUP BY 
 * 			A.F_ID, A.F_NAME, A.F_AGE, A.F_MONEY, B.F_ID, B.F_NAME,
 * 			B.F_AGE, B.F_MONEY, C.F_ID, C.F_NAME, C.F_AGE, C.F_MONEY, D.F_ID,
 * 			D.F_NAME, D.F_AGE, D.F_MONEY 
 * 		HAVING 
 * 			AVG(DISTINCT D.F_MONEY) > 1000
 * 		UNION ALL 
 * 			SELECT 
 * 				F_ID AS ID, F_NAME AS NAME, F_AGE AS AGE, F_MONEY AS  MONEY 
 * 			FROM 
 * 				CUSTOMER
 * 	) ALL_CONTENT
 */

// 分页查询
queryChain.getMapList();
/*
 * SELECT 
 * 		A.F_ID AS ID, 
 * 		B.F_NAME AS NAME, 
 * 		C.F_AGE AS AGE, 
 * 		D.F_MONEY AS MONEY 
 * FROM 
 * 		CUSTOMER A 
 * INNER JOIN CUSTOMER B ON B.F_ID = A.F_ID 
 * LEFT JOIN CUSTOMER C ON C.F_ID = B.F_ID 
 * INNER JOIN CUSTOMER D ON D.F_ID = C.F_ID 
 * WHERE 
 * 		(A.F_AGE >= 10 OR A.F_AGE <= 10) 
 * 		AND C.F_NAME LIKE '%王%'
 * 		AND D.F_MONEY NOT IN (3.5, 3.6, 3.7, 9.125, 10000.9) 
 * 		AND D.F_AGE IS NOT NULL 
 * 		AND D.F_AGE = (SELECT F_AGE FROM CUSTOMER WHERE F_AGE != 25)
 * GROUP BY 
 * 		A.F_ID, A.F_NAME, A.F_AGE, A.F_MONEY, B.F_ID, B.F_NAME,
 * 		B.F_AGE, B.F_MONEY, C.F_ID, C.F_NAME, C.F_AGE, C.F_MONEY, D.F_ID,
 * 		D.F_NAME, D.F_AGE, D.F_MONEY 
 * HAVING 
 * 		AVG(DISTINCT D.F_MONEY) > 1000
 * UNION ALL 
 * 		SELECT 
 * 			F_ID AS ID, F_NAME AS NAME, F_AGE AS AGE, F_MONEY AS  MONEY 
 * 		FROM 
 * 			CUSTOMER 
 * ORDER BY 
 * 		MONEY DESC 
 * LIMIT 40, 10
 */

###5.多样化的返回结果

// 除了上面用到过的getMapList,还有其它可选的返回值类型

// 您可以返回List泛型
queryChain.getList(Customer.class);

// 当您确定返回值只有一行数据时,您可以返回Pojo类型
queryChain.fetch(Customer.class);

// 当您确定返回值只有一行一列的时候,您可以这样
int avg = daoUtil.createQuery("select sum(f_age) ageSum from customer").getUnique(DaoType.INT);
System.out.println(avg);

// 如果说您想要自己封装返回值类型,您可以这样
queryChain.getResult(new QueryCallback<List<Customer>>() {

	@Override
	public List<Customer> getResult(ResultSet resultSet, String[] names) throws SQLException {
		List<Customer> customers = new ArrayList<Customer>();
		PojoBuilder<Customer> builder = QueryUtil.getPojoBuilder(Customer.class, resultSet, names);
		while (resultSet.next()) {
			Customer customer = builder.nextPojo();
			customer.setF_name("我想自己修改返回值");
			customers.add(customer);
		}
		return customers;
	}

});

###6.这里几乎包含所有您需要用到的增删改操作

// 首先试试新增操作
Customer customer = new Customer("张三", 19, 100);
daoUtil.insert("customer", customer);
System.out.println(customer.getF_id()); // 自动为Pojo对象生成了主键

// 批量新增
Customer[] customers = new Customer[] { //
// 两个对象
		new Customer("李四", 18, 100), //
		new Customer("王五", 17, 99) //
};
daoUtil.insert("customer", customers);
daoUtil.insert("customer", Arrays.asList(customers)); // 也可以使用集合

// 也可以采用链式调用的方式做新增
daoUtil.insertInto("customer").set("f_name = ?, f_age = 16,f_money = ?").execute("赵六", 105);

daoUtil.insertInto("customer").set("f_name = :name, f_age = :age")//
		.putParam("name", "田七")//
		.putParam("age", 15)//
		.execute();

// 然后试试修改操作
customer.setF_money(200);
daoUtil.update("customer", customer);
daoUtil.update("customer", Arrays.asList(customer, customer)); // 同样支持批量修改

daoUtil.updateFrom("customer")//
		.set("f_name = :newName, f_age = :newAge, f_money = 100")//
		.where("f_id = :oldName and f_age > :oldAge")//
		.putParam("newName", "新名字")//
		.putParam("newAge", 20).putParam("oldName", "旧名字")//
		.putParam("oldAge", 18)//
		.execute();

// 删除操作
daoUtil.deleteByID("customer", 18); // 通过主键删除
daoUtil.deleteByID("customer", 18, 19, 20); // 批量删除

daoUtil.deleteFrom("customer").where("f_name left like ?").execute("张三");// 名称像“张三%”的将被删除
daoUtil.deleteFrom("customer").execute();// 删除“customer”表的所有记录

#轻松与Spring进行集成

###Spring的设计的确是相当精妙,目前大多数项目都基于是Spring的容器来做的 ###Spring中提供了声明式事物、注解等等特性使得我们开发更加简单、容易 ###下面将演示如何在Spring中进行完美的集成(以下示例的所有源代码都在org.codefinger.test.spring包中能找到)

####首先是Spring的配置文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
						http://www.springframework.org/schema/beans/spring-beans.xsd 
						http://www.springframework.org/schema/tx 
						http://www.springframework.org/schema/tx/spring-tx.xsd 
						http://www.springframework.org/schema/context   
           				http://www.springframework.org/schema/context/spring-context.xsd
           				http://www.springframework.org/schema/aop
           				http://www.springframework.org/schema/aop/spring-aop.xsd">

	<!-- 阿里巴巴数据库连接池的SQL日志配置 -->
	<bean id="log-filter" class="com.alibaba.druid.filter.logging.Log4jFilter">
		<property name="resultSetLogEnabled" value="false" />
		<property name="statementExecutableSqlLogEnable" value="true" />
		<property name="statementLogEnabled" value="false" />
	</bean>

	<!-- 配置一下阿里巴巴的数据连接池,您可以采用其它的数据库连接池 -->
	<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
		init-method="init" destroy-method="close">
		<!-- <property name="url" value="jdbc:oracle:thin:@127.0.0.1:1521:orcl"></property> -->
		<!-- <property name="url" value="jdbc:sqlserver://127.0.0.1:1433;databaseName=dcode"></property> -->
		<property name="url"
			value="jdbc:mysql://192.168.189.135:3306/codefinger?useUnicode=true&amp;&amp;characterEncoding=utf-8"></property>
		<property name="username" value="root"></property>
		<property name="password" value="root"></property>
		<property name="proxyFilters">
			<list>
				<ref bean="log-filter" />
			</list>
		</property>

		<!-- 配置初始化大小、最小、最大 -->
		<property name="initialSize" value="1" />
		<property name="minIdle" value="1" />
		<property name="maxActive" value="20" />

		<!-- 配置获取连接等待超时的时间 -->
		<property name="maxWait" value="60000" />

		<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
		<property name="timeBetweenEvictionRunsMillis" value="60000" />

		<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
		<property name="minEvictableIdleTimeMillis" value="300000" />

		<property name="testWhileIdle" value="true" />
		<property name="testOnBorrow" value="false" />
		<property name="testOnReturn" value="false" />

		<!-- 打开PSCache,并且指定每个连接上PSCache的大小 -->
		<property name="poolPreparedStatements" value="true" />
		<property name="maxPoolPreparedStatementPerConnectionSize"
			value="20" />

		<!-- 配置监控统计拦截的filters -->
		<!-- <property name="filters" value="stat" /> -->
	</bean>

	<!-- 事物管理对象 -->
	<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource"></property>
	</bean>

	<!-- 数据源代理对象 -->
	<bean id="transactionAwareDataSourceProxy" class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy">
		<property name="targetDataSource" ref="dataSource"></property>
	</bean>

	<!-- 这样您就可以使用注解式的事物 -->
	<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />

	<!-- 这是声明式事物配置,配置事务传播特性 -->
	<tx:advice id="TestAdvice" transaction-manager="transactionManager">
		<tx:attributes>
			<tx:method name="save*" propagation="REQUIRED" />
			<tx:method name="del*" propagation="REQUIRED" />
			<tx:method name="update*" propagation="REQUIRED" />
			<tx:method name="add*" propagation="REQUIRED" />
			<tx:method name="find*" propagation="REQUIRED" />
			<tx:method name="get*" propagation="REQUIRED" />
			<tx:method name="apply*" propagation="REQUIRED" />
		</tx:attributes>
	</tx:advice>
	<!-- 配置参与事务的类 -->
	<aop:config>
		<aop:pointcut id="allTestServiceMethod" expression="execution(* org.codefinger.test.spring.*.*(..))" />
		<aop:advisor pointcut-ref="allTestServiceMethod" advice-ref="TestAdvice" />
	</aop:config>

	<!-- 数据库工具配置 -->
	<bean id="daoUtil" class="org.codefinger.dao.DaoUtil">
		<!-- 如需事物生效,必须使用Spring的DataSource代理才行(网上好多教程中的事物没配置代理,其实根本就不生效) -->
		<property name="dataSource" ref="transactionAwareDataSourceProxy"></property>
	</bean>

	<!-- 这时,您可以将复杂的查询配置在Spring的配置文件中(您也可以将SQL配置到单独的Spring配置文件中,然后import进来,这是不是像MyBatis) -->
	<bean id="queryCustomer" class="org.codefinger.dao.SpringQuery">
		<property name="sql">
			<value>
				<![CDATA[
					select
						A.f_id id,
						B.f_name as name,
						C.f_age age,
						D.f_money as money
					from  
						customer A  
						inner join customer B on B.f_id = A.f_id  
						left join customer C on C.f_id = B.f_id  
						inner join customer D on D.f_id = C.f_id  
					where  
							(A.f_age >= :minAge or A.f_age <= :minAge)  
							and B.f_name left like :leftName  
							and C.f_name all like :allName  
							and D.f_money not in (3.5,3.6,:moneyNotIn)  
							and D.f_age is not null  
							and D.f_age = (select f_age from customer where f_age != :notAge)  
					group by  
							A.*,B.*,C.*,D.*  
					having  
							AVG(D.f_money) > 1000  
					union all  
							select  
								f_id id, 
								f_name name, 
								f_age as age, 
								f_money money  
							from 
								customer  
					order by  
							money desc,age asc
				]]>
			</value>
		</property>
	</bean>

	<!-- 让Spring扫描我们的控制层 -->
	<context:component-scan base-package="org.codefinger.test.spring" />

</beans>

####然后我们可以写个Service试试

package org.codefinger.test.spring;

import java.util.List;
import java.util.Map;

import org.codefinger.dao.DaoUtil;
import org.codefinger.dao.Query;
import org.codefinger.test.Customer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

/***
 * <p>
 * 您可以把{@link MyService}当作为您项目中Action、Controller、Service等等<br/>
 * </p>
 * 
 * @author jack
 *
 */
@Service
public class MyService {

	/**
	 * 从Spring获取配置好的SQL
	 */
	@Autowired
	@Qualifier("queryCustomer")
	private Query	queryCustomer;

	/**
	 * 自动注入数据库工具
	 */
	@Autowired
	private DaoUtil	daoUtil;

	/**
	 * 根据最小年龄和名称做模糊查询
	 * 
	 * @param minAge
	 * @param allName
	 * @return
	 */
	public List<Map<String, Object>> getMapList(int minAge, String allName) {
		return queryCustomer.putParam("minAge", minAge).putParam("allName", allName).getMapList();
	}

	/**
	 * 添加
	 * 
	 * @param customer
	 * @return
	 */
	public boolean add(Customer customer) {
		return daoUtil.insert("customer", customer);
	}

	/**
	 * 修改
	 * 
	 * @param customer
	 * @return
	 */
	public boolean update(Customer customer) {
		return daoUtil.update("customer", customer);
	}

	/*
	 * 当然,您还能用它做更多的数据访问工作(复杂的修改、删除、分页等等),这就又您自由发挥了......
	 */

}

####最后看看成果

package org.codefinger.test.spring;

import org.codefinger.test.Customer;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SpringDemo {

	@SuppressWarnings("resource")
	public static void main(String[] args) {
		// 这里做演示,手动加载Spring文件(实际项目中Spring配置文件可能在Web容器中做加载,但原理都是一样)
		ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");

		// 从容器中获取我们的控制层做测试
		MyService myService = applicationContext.getBean(MyService.class);

		myService.getMapList(15, "张三");

		myService.add(new Customer("李四", 20, 100));

		myService.update(new Customer("王五", 17, 30));

	}

}

#最近跟新

  • 增加了getByID功能,可以直接根据主键查找对象

#*注意,使用前提

  • 每张表都必须且只能包含一个“长整型”的主键。(其中对于SQLServer数据库,必须手动将主键设置为自增)
  • 每个与数据库对应的实体类,主键必须是long或者java.util.Long类型
  • 对于和数据库映射的日期时间类型统一为java.util.Date

#附件中有一个编译好的版本,可以直接使用

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: You must give any other recipients of the Work or Derivative Works a copy of this License; and You must cause any modified files to carry prominent notices stating that You changed the files; and You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2015 codefinger Licensed 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.

简介

Java数据库访问工具 展开 收起
Java
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/codefinger/codefinger-dao.git
git@gitee.com:codefinger/codefinger-dao.git
codefinger
codefinger-dao
codefinger-dao
master

搜索帮助