James 7 年 前
コミット
9631285063
1 ファイル変更1 行追加1 行削除
  1. 1 1
      src/main/java/com/jfinal/plugin/activerecord/Model.java

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

@@ -571,7 +571,7 @@ public abstract class Model<M extends Model> implements Serializable {
 	public boolean delete() {
 	public boolean delete() {
 		Table table = _getTable();
 		Table table = _getTable();
 		String[] pKeys = table.getPrimaryKey();
 		String[] pKeys = table.getPrimaryKey();
-		if (pKeys.length == 1) {
+		if (pKeys.length == 1) {	// 优化:主键大概率只有一个
 			Object id = attrs.get(pKeys[0]);
 			Object id = attrs.get(pKeys[0]);
 			if (id == null)
 			if (id == null)
 				throw new ActiveRecordException("Primary key " + pKeys[0] + " can not be null");
 				throw new ActiveRecordException("Primary key " + pKeys[0] + " can not be null");