Skip to content

Commit f4fa9ca

Browse files
committed
add commonts
1 parent faff522 commit f4fa9ca

36 files changed

Lines changed: 268 additions & 328 deletions

bin/dbconfig.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ URL=jdbc:mysql://localhost:3306/opendb
99
USERNAME=root
1010
#database pass
1111
#USERPWD=P@ssw0rd
12-
USERPWD=123456
12+
USERPWD=123456
13+
DIALECT=MYSQL

src/dbconfig.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ URL=jdbc:mysql://localhost:3306/opendb
99
USERNAME=root
1010
#database pass
1111
#USERPWD=P@ssw0rd
12-
USERPWD=123456
12+
USERPWD=123456
13+
DIALECT=MYSQL

src/openthinks/libs/sql/dao/BaseDao.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
* @author dmj
2222
* @version 2010/11/15
23-
* @param <E>
23+
* @param <T>
2424
*/
2525
public interface BaseDao {
2626

@@ -29,7 +29,7 @@ public interface BaseDao {
2929
* @return boolean
3030
*/
3131
public boolean isUsePool();
32-
32+
3333
/**
3434
* 取得数据库连接
3535
*
@@ -171,13 +171,15 @@ public interface BaseDao {
171171
* <li>无配置默认实体类中的各属性字段与数据库表中的字段名称相同,区分大小写.
172172
* </ol>
173173
* @deprecated
174+
* please use: {@code <T> List<T> openthinks.libs.sql.dao.BaseDao.list(Class<T> clz, String sql)}
174175
* @see Entity </span>
175176
* @param clz
176177
* 查询的实体Class类型,<font color=red><b>需是Entity的子类型</b></font>
177178
* @param sql
178179
* 标准查询sql语句,<span style=color:red>不支持跨表查询</span>
179-
* @return List<E> 实体类Entity或其子类的集合列表
180+
* @return List<T> 实体类Entity或其子类的集合列表
180181
*/
182+
@Deprecated
181183
public <T extends Entity> List<T> listEntity(Class<T> clz, String sql);
182184

183185
/**
@@ -189,17 +191,18 @@ public interface BaseDao {
189191
* <li>无配置默认实体类中的各属性字段与数据库表中的字段名称相同,区分大小写.
190192
* </ol>
191193
* @deprecated
194+
* please use: {@code <T> List<T> openthinks.libs.sql.dao.BaseDao.list(Class<T> clz, String sql, String[] params)}
192195
* @see Entity </span>
193196
* @param clz
194197
* 查询的实体Class类型,<font color=red><b>需是Entity的子类型</b></font>
195198
* @param sql
196199
* 标准查询sql语句,<span style=color:red>不支持跨表查询</span>
197200
* @param params
198201
* sql语句依赖的具体参数数组
199-
* @return List<E> 实体类Entity或其子类的集合列表
202+
* @return List<T> 实体类Entity或其子类的集合列表
200203
*/
201-
public <T extends Entity> List<T> listEntity(Class<T> clz, String sql,
202-
String[] params);
204+
@Deprecated
205+
public <T extends Entity> List<T> listEntity(Class<T> clz, String sql, String[] params);
203206

204207
/**
205208
* 返回满足查询条件的实体类的集合列表<br>
@@ -209,16 +212,17 @@ public <T extends Entity> List<T> listEntity(Class<T> clz, String sql,
209212
* <li>实体类重写父类Entity的get,set方法
210213
* <li>无配置默认实体类中的各属性字段与数据库表中的字段名称相同,区分大小写.
211214
* </ol>
212-
* @deprecated
215+
* @deprecated
216+
* please use: {@code <T> List<T> openthinks.libs.sql.dao.BaseDao.list(Class<T> clz, Condition condition)}
213217
* @see Entity </span>
214218
* @param clz
215219
* 查询的实体Class类型,<font color=red><b>需是Entity的子类型</b></font>
216220
* @param condition
217221
* 专用于生成带条件的sql语句的对象
218-
* @return List<E> 实体类Entity或其子类的集合列表
222+
* @return List<T> 实体类Entity或其子类的集合列表
219223
*/
220-
public <T extends Entity> List<T> listEntity(Class<T> clz,
221-
Condition condition);
224+
@Deprecated
225+
public <T extends Entity> List<T> listEntity(Class<T> clz, Condition condition);
222226

223227
/**
224228
* 返回所有相应实体类的集合列表<br>
@@ -251,10 +255,10 @@ public <T extends Entity> List<T> listEntity(Class<T> clz,
251255
* 1.Entity子类<BR>
252256
* 2.JPA注解方式
253257
* @since 2010/11/17
254-
* @return List<E> 任何实体类的集合列表
258+
* @return List<T> 任何实体类的集合列表
255259
*/
256-
public <T> List<T> list(Class<T> clz);
257-
260+
public <T> List<T> list(Class<T> clz);
261+
258262
/**
259263
* 返回满足查询条件的实体类的集合列表<br>
260264
* <span style=color:gray;> 遵循数据库表结构反射. 实体类中的各属性字段与数据库表中的字段名称相同,区分大小写.<br>

src/openthinks/libs/sql/dhibernate/Session.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,21 @@
2121
*/
2222
public interface Session {
2323

24+
/**
25+
* create a {@link Query} for this given entity class
26+
* @param clz Class<T> entity class type
27+
* @return Query<T>
28+
*/
2429
public <T> Query<T> createQuery(Class<T> clz);
2530

2631
/**
2732
* 根据id值获取clz类型的实体对象
2833
*
2934
* @param clz
3035
* 实体类型clz<BR>
31-
* 1.Entity子类默认第一个熟悉为ID列<BR>
36+
* 1.{@link Entity}子类默认第一个属性为ID列<BR>
3237
* 2.JPA标注的实体类标准 {@link javax.persistence.Id}
33-
* @param id
38+
* @param id Serializable
3439
* 主键值
3540
* @return Object 数据库表所对应的实体对象
3641
*/
@@ -102,7 +107,7 @@ public interface Session {
102107
*
103108
* @param clz
104109
* 查询的实体Class类型,<span style=color:red>可以不是Entity的子类</span><BR>
105-
* 1.Entity子类<BR>
110+
* 1.{@link Entity}子类<BR>
106111
* 2.JPA注解方式
107112
* @since 2010/11/17
108113
* @return List<E> 任何实体类的集合列表
@@ -310,10 +315,14 @@ public interface Session {
310315
*/
311316
public Configurator getConfigurator();
312317

318+
/**
319+
* judge database connection is auto-close after execute DML
320+
* @return Boolean
321+
*/
313322
public Boolean isAutoClose();
314323

315324
/**
316-
* controller connection auto-close when after execute DML
325+
* controller database connection auto-close when after execute DML
317326
*
318327
*/
319328
public void enableAutoClose();

src/openthinks/libs/sql/dhibernate/support/AbstractSession.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*
1919
* @Title: AbstractSession.java
20-
* @Package sql.dhibernate.support
20+
* @Package openthinks.libs.sql.dhibernate.support
2121
* @Description: TODO
2222
* @author minjdai
2323
* @date 2013-12-2
@@ -75,12 +75,13 @@ protected void setAutoClose(Boolean autoClose) {
7575
}
7676

7777
/**
78-
* @return
78+
* provider the {@link BaseDao}
79+
* @return BaseDao
7980
*/
8081
public abstract BaseDao getBaseDao();
8182

8283
/**
83-
* @return the autoClose
84+
* @return Boolean if is autoClose
8485
*/
8586
@Override
8687
public Boolean isAutoClose() {
@@ -94,8 +95,7 @@ public <T> T load(Class<T> clz, Serializable id) {
9495
Checker.require(persistName).notNull();
9596
String persistIdName = ReflectEngine.getEntityID(clz);
9697
Checker.require(persistIdName).notNull();
97-
String sql = "SELECT * FROM " + persistName + " WHERE " + persistIdName
98-
+ " = ?";
98+
String sql = "SELECT * FROM " + persistName + " WHERE " + persistIdName + " = ?";
9999
return get(clz, sql, new String[] { id.toString() });
100100
}
101101

@@ -165,8 +165,7 @@ public <T> T get(Class<T> clz, String sql, String[] params) {
165165
try {
166166
String columnName = rsmd.getColumnName(i);
167167
Object columnValue = rs.getObject(columnName);
168-
ReflectEngine.propertyReflect(entity, columnName,
169-
columnValue);
168+
ReflectEngine.propertyReflect(entity, columnName, columnValue);
170169
} catch (Exception e) {
171170
getBaseDao().getLogger().warn(e.getMessage());
172171
continue;
@@ -200,8 +199,7 @@ public <T extends Entity> T get(Entity entity, String sql, String[] params) {
200199
try {
201200
String columnName = rsmd.getColumnName(i);
202201
Object columnValue = rs.getObject(columnName);
203-
ReflectEngine.propertyReflect(entity, columnName,
204-
columnValue);
202+
ReflectEngine.propertyReflect(entity, columnName, columnValue);
205203
// entity.set(columnName, columnValue);
206204
} catch (Exception e) {
207205
getBaseDao().getLogger().warn(e.getMessage());
@@ -229,15 +227,13 @@ public <T> List<T> list(Class<T> clz) {
229227
*/
230228
@Override
231229
public <T> T get(Class<T> clz, Condition condition) {
232-
return condition == null ? null : get(clz,
233-
Condition.getFullSql(condition));
230+
return condition == null ? null : get(clz, Condition.getFullSql(condition));
234231
}
235232

236233
@SuppressWarnings("unchecked")
237234
@Override
238235
public <T extends Entity> T get(Entity entity, Condition condition) {
239-
return (T) (condition == null ? null : get(entity,
240-
Condition.getFullSql(condition)));
236+
return (T) (condition == null ? null : get(entity, Condition.getFullSql(condition)));
241237
}
242238

243239
/**

src/openthinks/libs/sql/dhibernate/support/ColumnAttribute.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*
1919
* @Title: ColumnAttribute.java
20-
* @Package sql.dhibernate.support
20+
* @Package openthinks.libs.sql.dhibernate.support
2121
* @Description: TODO
2222
* @author dailey
2323
* @date 2012-11-9

src/openthinks/libs/sql/dhibernate/support/ColumnAttributeMapping.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*
1919
* @Title: ColumnAttributeMapping.java
20-
* @Package sql.dhibernate.support
20+
* @Package openthinks.libs.sql.dhibernate.support
2121
* @Description: TODO
2222
* @author dailey
2323
* @date 2012-11-9

src/openthinks/libs/sql/dhibernate/support/DefaultSession.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,11 @@ public DefaultSession(Configurator configurator) {
2121
baseDao.setConfigurator(configurator);
2222
}
2323

24-
/*
25-
* (non-Javadoc)
26-
*
27-
* @see sql.dhibernate.support.AbstractSession#getBaseDao()
28-
*/
2924
@Override
3025
public BaseDao getBaseDao() {
3126
return baseDao;
3227
}
3328

34-
/*
35-
* (non-Javadoc)
36-
*
37-
* @see
38-
* sql.dhibernate.support.AbstractSession#setAutoClose(java.lang.Boolean)
39-
*/
4029
@Override
4130
protected void setAutoClose(Boolean autoClose) {
4231
super.setAutoClose(autoClose);

src/openthinks/libs/sql/dhibernate/support/FilterTemplate.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*
1919
* @Title: FilterTemplate.java
20-
* @Package sql.dhibernate.support
20+
* @Package openthinks.libs.sql.dhibernate.support
2121
* @Description: TODO
2222
* @author minjdai
2323
* @date 2013-12-2
@@ -28,8 +28,8 @@
2828
import openthinks.libs.sql.dhibernate.support.query.QueryFilter;
2929

3030
/**
31+
* generate the query filter part sql, which the <B>WHERE</B> part in <B>SELECT</B> statement
3132
* @author minjdai
32-
*
3333
*/
3434
public interface FilterTemplate extends Template {
3535

@@ -41,6 +41,10 @@ public interface FilterTemplate extends Template {
4141
*/
4242
public void setFilter(QueryFilter filters);
4343

44+
/**
45+
* get the filter values
46+
* @return Object[]
47+
*/
4448
public Object[] getParameters();
4549

4650
}

src/openthinks/libs/sql/dhibernate/support/IDType.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*
1919
* @Title: IDType.java
20-
* @Package sql.dhibernate.support
20+
* @Package openthinks.libs.sql.dhibernate.support
2121
* @Description: TODO
2222
* @author dailey
2323
* @date 2012-11-9
@@ -26,7 +26,7 @@
2626
package openthinks.libs.sql.dhibernate.support;
2727

2828
/**
29-
* The primary key type for database table
29+
* The generate strategy of primary key value for database table
3030
* @author dailey
3131
*
3232
*/

0 commit comments

Comments
 (0)