2012-08-17 16 views
0

爲道的Javadoc刷新()的方法規定:OrmLite不刷新拋出異常沒有結果

拋出: 的SQLException - 任何SQL問題,或者如果數據項不能在表中找到或者如果找到多個具有數據ID的項目。

但是該類com.j256.ormlite.stmt.mapped.MappedRefresh有另外的Javadoc定義並返回結果代碼一路回升到刷新並給用戶。

/** 
* Execute our refresh query statement and then update all of the fields in data with the fields from the result. 
* 
* @return 1 if we found the object in the table by id or 0 if not. 
*/ 
public int executeRefresh(DatabaseConnection databaseConnection, T data, ObjectCache objectCache) 
     throws SQLException { 
    @SuppressWarnings("unchecked") 
    ID id = (ID) idField.extractJavaFieldValue(data); 
    // we don't care about the cache here 
    T result = super.execute(databaseConnection, id, null); 
    if (result == null) { 
     return 0; 
    } 
    // copy each field from the result into the passed in object 
    for (FieldType fieldType : resultsFieldTypes) { 
     if (fieldType != idField) { 
      fieldType.assignField(data, fieldType.extractJavaFieldValue(result), false, objectCache); 
     } 
    } 
    return 1; 
} 

這是一個錯誤還是Dao.refresh的Javadoc錯誤?

我正在看OrmLite 4.41。

+0

我的回答對你有幫助嗎?如果可以,請接受:http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work – Gray 2012-09-26 20:34:39

回答

0

內部方法通常沒有完美的Javadocs,因爲它只適用於開發人員。另外,我傾向於不記錄每個拋出的異常。

在這種情況下,MappedRefresh.executeRefresh(...)方法文檔看起來相當不錯,只是它沒有記錄異常。如果你看一下super.execute(...)線,電話MappedQueryForId.execute(...),你可以看到它具有以下測試/扔:

​​

fieldType.assignField(...)等方法也可以在各種數據或數據庫的問題拋出SQLException

所以Dao.refresh(...) javadocs是正確的。 javadocs也是正確的,但缺少有關例外的詳細信息。