@Override
 public long save(Object entity) {
   acquireReference();
   try {
     SQLiteDatabase db = mHelper.getWritableDatabase();
     mTableManager.checkOrCreateTable(db, entity);
     return SQLBuilder.buildReplaceSql(entity).execInsertWithMapping(db, entity, mTableManager);
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     releaseReference();
   }
   return SQLStatement.NONE;
 }
 @Override
 public int insert(Collection<?> collection, ConflictAlgorithm conflictAlgorithm) {
   acquireReference();
   try {
     if (!Checker.isEmpty(collection)) {
       SQLiteDatabase db = mHelper.getWritableDatabase();
       Object entity = collection.iterator().next();
       SQLStatement stmt = SQLBuilder.buildInsertAllSql(entity, conflictAlgorithm);
       mTableManager.checkOrCreateTable(db, entity);
       return stmt.execInsertCollection(db, collection, mTableManager);
     }
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     releaseReference();
   }
   return SQLStatement.NONE;
 }