浏览代码

jfinal 3.6

James 7 年之前
父节点
当前提交
3f18b0f767

+ 6 - 6
src/main/java/com/jfinal/plugin/activerecord/Db.java

@@ -315,18 +315,18 @@ public class Db {
 	}
 	
 	/**
-	 * Find record by id.
+	 * Find record by ids.
 	 * <pre>
 	 * Example:
-	 * Record user = Db.findById("user", "user_id", 123);
-	 * Record userRole = Db.findById("user_role", "user_id, role_id", 123, 456);
+	 * Record user = Db.findByIds("user", "user_id", 123);
+	 * Record userRole = Db.findByIds("user_role", "user_id, role_id", 123, 456);
 	 * </pre>
 	 * @param tableName the table name of the table
 	 * @param primaryKey the primary key of the table, composite primary key is separated by comma character: ","
-	 * @param idValue the id value of the record, it can be composite id values
+	 * @param idValues the id value of the record, it can be composite id values
 	 */
-	public static Record findById(String tableName, String primaryKey, Object... idValue) {
-		return MAIN.findById(tableName, primaryKey, idValue);
+	public static Record findById(String tableName, String primaryKey, Object... idValues) {
+		return MAIN.findByIds(tableName, primaryKey, idValues);
 	}
 	
 	/**

+ 8 - 8
src/main/java/com/jfinal/plugin/activerecord/DbPro.java

@@ -390,27 +390,27 @@ public class DbPro {
 	 * @param idValue the id value of the record
 	 */
 	public Record findById(String tableName, Object idValue) {
-		return findById(tableName, config.dialect.getDefaultPrimaryKey(), idValue);
+		return findByIds(tableName, config.dialect.getDefaultPrimaryKey(), idValue);
 	}
 	
 	/**
-	 * Find record by id.
+	 * Find record by ids.
 	 * <pre>
 	 * Example:
-	 * Record user = DbPro.use().findById("user", "user_id", 123);
-	 * Record userRole = DbPro.use().findById("user_role", "user_id, role_id", 123, 456);
+	 * Record user = DbPro.use().findByIds("user", "user_id", 123);
+	 * Record userRole = DbPro.use().findByIds("user_role", "user_id, role_id", 123, 456);
 	 * </pre>
 	 * @param tableName the table name of the table
 	 * @param primaryKey the primary key of the table, composite primary key is separated by comma character: ","
-	 * @param idValue the id value of the record, it can be composite id values
+	 * @param idValues the id value of the record, it can be composite id values
 	 */
-	public Record findById(String tableName, String primaryKey, Object... idValue) {
+	public Record findByIds(String tableName, String primaryKey, Object... idValues) {
 		String[] pKeys = primaryKey.split(",");
-		if (pKeys.length != idValue.length)
+		if (pKeys.length != idValues.length)
 			throw new IllegalArgumentException("primary key number must equals id value number");
 		
 		String sql = config.dialect.forDbFindById(tableName, pKeys);
-		List<Record> result = find(sql, idValue);
+		List<Record> result = find(sql, idValues);
 		return result.size() > 0 ? result.get(0) : null;
 	}