dbhelper

A easy based on the Spring JdbcTemplate JDBC helper

License

License

GroupId

GroupId

com.denghb
ArtifactId

ArtifactId

dbhelper
Last Version

Last Version

3.0.6
Release Date

Release Date

Type

Type

jar
Description

Description

dbhelper
A easy based on the Spring JdbcTemplate JDBC helper
Project URL

Project URL

https://github.com/deng-hb/dbhelper
Source Code Management

Source Code Management

https://github.com/deng-hb/dbhelper

Download dbhelper

How to add to project

<!-- https://jarcasting.com/artifacts/com.denghb/dbhelper/ -->
<dependency>
    <groupId>com.denghb</groupId>
    <artifactId>dbhelper</artifactId>
    <version>3.0.6</version>
</dependency>
// https://jarcasting.com/artifacts/com.denghb/dbhelper/
implementation 'com.denghb:dbhelper:3.0.6'
// https://jarcasting.com/artifacts/com.denghb/dbhelper/
implementation ("com.denghb:dbhelper:3.0.6")
'com.denghb:dbhelper:jar:3.0.6'
<dependency org="com.denghb" name="dbhelper" rev="3.0.6">
  <artifact name="dbhelper" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.denghb', module='dbhelper', version='3.0.6')
)
libraryDependencies += "com.denghb" % "dbhelper" % "3.0.6"
[com.denghb/dbhelper "3.0.6"]

Dependencies

compile (1)

Group / Artifact Type Version
org.springframework : spring-jdbc jar 4.3.0.RELEASE

Project Modules

There are no modules declared in this project.

dbhelper

一个简单的基于Spring JdbcTemplate帮助包 (暂时只支持mysql)

1、Maven

<dependency>
  <groupId>com.denghb</groupId>
  <artifactId>dbhelper</artifactId>
  <version>3.0.6</version>
</dependency>

Or

git clone https://github.com/deng-hb/dbhelper.git

2、配置 SpringBoot 参考spring-boot-dbhelper-demo

在Spring配置文件(applicationContext.xml)中增加

<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
	<property name="dataSource">
		<ref bean="dataSource" />
	</property>
</bean>

<bean id="dbHepler" class="com.denghb.dbhelper.impl.DbHelperImpl">
	<property name="jdbcTemplate" ref="jdbcTemplate"></property>		
</bean>

Or 下载源码使用注解(jdbcTemplate需要在配置中)

@Repository
public class DbHelperImpl implements DbHelper {

  	@Repository
	private JdbcTemplate jdbcTemplate;

Logging配置(application.properties/log4j.properties):

logging.level.com.denghb=DEBUG

3、使用

/**
 * 创建一条纪录
 *
 * @param object
 * @return
 */
public boolean insert(Object object);

/**
 * 更新一条纪录
 *
 * @param object
 * @return
 */
public boolean updateById(Object object);

/**
 * 执行一条SQL
 *
 * @param sql
 * @param args
 * @return
 */
public int execute(String sql, Object... args);

/**
 * 查询列表
 *
 * @param sql
 * @param clazz
 * @param args
 * @return
 */
public <T> List<T> list(String sql, Class<T> clazz, Object... args);


/**
 * 查询并分页
 *
 * @param sql
 * @param clazz
 * @param paging
 * @param <T>
 * @return
 */
public <T> PagingResult<T> list(StringBuffer sql, Class<T> clazz, Paging paging);

/**
 * 指定参数查询返回对象
 *
 * @param sql
 * @param clazz
 * @param args
 * @return
 */
public <T> T queryForObject(String sql, Class<T> clazz, Object... args);

/**
 * 查询一条纪录
 *
 * @param clazz
 * @param id
 * @return
 */
public <T> T queryById(Class<T> clazz, Object id);

/**
 * 删除
 *
 * @param clazz
 * @param id
 * @return
 */
public <T> boolean deleteById(Class<T> clazz, Object id);

4、兼容 spring-jdbc 3.1.0.RELEASE 及以上版本

5、数据库表生成对应实体dbhelper-client

6、欢迎拍砖(issues||i#denghb.com)#->@

7、License

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.

Versions

Version
3.0.6
3.0.5
3.0.4
3.0.3
3.0.2
3.0.1
2.0
1.9
1.8
1.7
1.6
1.5
1.4
1.3
1.2
1.0