Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Licensed to JumpMind Inc under one or more contributor
* license agreements. See the NOTICE file distributed
* with this work for additional information regarding
* copyright ownership. JumpMind Inc licenses this file
* to you under the GNU General Public License, version 3.0 (GPLv3)
* (the "License"); you may not use this file except in compliance
* with the License.
*
* You should have received a copy of the GNU General Public License,
* version 3.0 (GPLv3) along with this library; if not, see
* .
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jumpmind.symmetric.android;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.jumpmind.db.model.Table;
import org.jumpmind.db.sql.ISqlRowMapper;
import org.jumpmind.db.sql.ISqlTransaction;
import android.database.sqlite.SQLiteDatabase;
public class AndroidSqlTransaction implements ISqlTransaction {
protected AndroidSqlTemplate sqlTemplate;
protected SQLiteDatabase database;
protected boolean oldAutoCommitValue;
protected String sql;
protected boolean needsRolledback = false;
public AndroidSqlTransaction(AndroidSqlTemplate sqlTemplate) {
this.sqlTemplate = sqlTemplate;
this.database = sqlTemplate.getDatabaseHelper().getWritableDatabase();
this.database.beginTransaction();
}
public void setInBatchMode(boolean batchMode) {
}
public boolean isInBatchMode() {
return false;
}
public List query(String sql, ISqlRowMapper mapper, Map namedParams) {
return sqlTemplate.query(sql, mapper, namedParams);
}
public List query(String sql, ISqlRowMapper mapper, Object[] args, int[] types) {
return sqlTemplate.query(sql, mapper, args, types);
}
public T queryForObject(String sql, Class clazz, Object... args) {
return this.sqlTemplate.queryForObject(database, sql, clazz, args);
}
public void commit() {
try {
this.database.setTransactionSuccessful();
} catch (Exception ex) {
throw this.sqlTemplate.translate(ex);
} finally {
this.database.endTransaction();
this.database.beginTransaction();
}
}
public void rollback() {
needsRolledback = true;
}
public void close() {
if (!needsRolledback) {
this.database.setTransactionSuccessful();
}
this.database.endTransaction();
this.database = null;
}
public void prepare(String sql) {
this.sql = sql;
}
public int addRow(T marker, Object[] values, int[] types) {
return this.sqlTemplate.update(database, sql, values, types);
}
public int flush() {
return 0;
}
public int queryForInt(String sql, Object... args) {
return sqlTemplate.queryForObject(database, sql, Integer.class, args);
}
public long queryForLong(String sql, Object... args) {
return sqlTemplate.queryForObject(database, sql, Long.class, args);
}
public int execute(String sql) {
return sqlTemplate.update(database, sql, null, null);
}
public int prepareAndExecute(String sql, Object[] args, int[] types) {
return sqlTemplate.update(database, sql, args, types);
}
public int prepareAndExecute(String sql, Object... args) {
return sqlTemplate.update(database, sql, args, null);
}
public List