Browse Source

jfinal 3.2 release

James 8 years ago
parent
commit
7508e94c71

+ 6 - 4
src/main/java/com/jfinal/plugin/activerecord/dialect/Dialect.java

@@ -77,7 +77,8 @@ public abstract class Dialect {
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Get id after save method.
+	 * 用于获取 Model.save() 以后自动生成的主键值,可通过覆盖此方法实现更精细的控制
+	 * 目前只有 PostgreSqlDialect,覆盖过此方法
 	 */
 	 */
 	public void getModelGeneratedKey(Model<?> model, PreparedStatement pst, Table table) throws SQLException {
 	public void getModelGeneratedKey(Model<?> model, PreparedStatement pst, Table table) throws SQLException {
 		String[] pKeys = table.getPrimaryKey();
 		String[] pKeys = table.getPrimaryKey();
@@ -92,7 +93,7 @@ public abstract class Dialect {
 						} else if (colType == Long.class || colType == long.class) {
 						} else if (colType == Long.class || colType == long.class) {
 							model.set(pKey, rs.getLong(1));
 							model.set(pKey, rs.getLong(1));
 						} else {
 						} else {
-							model.set(pKey, rs.getObject(1));		// It returns Long object for int colType
+							model.set(pKey, rs.getObject(1));	// It returns Long for int colType for mysql
 						}
 						}
 					}
 					}
 				}
 				}
@@ -102,14 +103,15 @@ public abstract class Dialect {
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Get id after save record.
+	 * 用于获取 Db.save(tableName, record) 以后自动生成的主键值,可通过覆盖此方法实现更精细的控制
+	 * 目前只有 PostgreSqlDialect,覆盖过此方法
 	 */
 	 */
 	public void getRecordGeneratedKey(PreparedStatement pst, Record record, String[] pKeys) throws SQLException {
 	public void getRecordGeneratedKey(PreparedStatement pst, Record record, String[] pKeys) throws SQLException {
 		ResultSet rs = pst.getGeneratedKeys();
 		ResultSet rs = pst.getGeneratedKeys();
 		for (String pKey : pKeys) {
 		for (String pKey : pKeys) {
 			if (record.get(pKey) == null || isOracle()) {
 			if (record.get(pKey) == null || isOracle()) {
 				if (rs.next()) {
 				if (rs.next()) {
-					record.set(pKey, rs.getObject(1));
+					record.set(pKey, rs.getObject(1));	// It returns Long for int colType for mysql
 				}
 				}
 			}
 			}
 		}
 		}