ソースを参照

List<M> find(Config, Connection, String, Object...) 可见性改为 protected

James 5 年 前
コミット
a53aeda8a6

+ 0 - 4
src/main/java/com/jfinal/plugin/activerecord/CPI.java

@@ -92,10 +92,6 @@ public abstract class CPI {
 		return Db.find(DbKit.getConfig(configName), conn, sql, paras);
 	}
 	
-	public static List<Model> find(Model model, Config config, Connection conn, String sql, Object... paras) throws Exception {
-		return model.find(config, conn, sql, paras);
-	}
-	
 	public static Page<Record> paginate(Connection conn, int pageNumber, int pageSize, String select, String sqlExceptSelect, Object... paras) throws SQLException {
 		return Db.paginate(DbKit.config, conn, pageNumber, pageSize, select, sqlExceptSelect, paras);
 	}

+ 4 - 1
src/main/java/com/jfinal/plugin/activerecord/Model.java

@@ -679,8 +679,11 @@ public abstract class Model<M extends Model> implements Serializable {
 	
 	/**
 	 * Find model.
+	 * 
+	 * 警告:传入的 Connection 参数需要由传入者在 try finally 块中自行
+	 *      关闭掉,否则将出现 Connection 资源不能及时回收的问题
 	 */
-	List<M> find(Config config, Connection conn, String sql, Object... paras) throws Exception {
+	protected List<M> find(Config config, Connection conn, String sql, Object... paras) throws Exception {
 		try (PreparedStatement pst = conn.prepareStatement(sql)) {
 			config.dialect.fillStatement(pst, paras);
 			ResultSet rs = pst.executeQuery();