Fix some problems when the Dao class generate an exception.