Updated begin and end transaction methods

This commit is contained in:
Juan Miguel Boyero Corral 2013-09-13 22:02:31 +02:00
parent 892712e6cb
commit 8645aae18d

View File

@ -308,7 +308,8 @@ public class DataBaseHelper {
ent.getInt("multiple"),
ent.getLong("openTime"));
} else if (table.equals(Constants.DB_TABLE_PRACTICE_SESSIONS)) {
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm");
//SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm");
java.text.DateFormat format = SimpleDateFormat.getDateTimeInstance();
try {
o = new PracticeSession(ent.getId(),
@ -962,7 +963,7 @@ public class DataBaseHelper {
//it should not insert/modify rows in the relationship table if the course does not exists
if (course != null) {
if (rows.isEmpty()) {
PairTable<Long, Long> pair = new PairTable(Constants.DB_TABLE_GROUPS_COURSES, g.getId(), courseCode);
PairTable<Long, Long> pair = new PairTable<Long, Long>(Constants.DB_TABLE_GROUPS_COURSES, g.getId(), courseCode);
insertPairTable(pair);
} else {
rows.get(0).setValue("crsCod", courseCode);
@ -981,7 +982,9 @@ public class DataBaseHelper {
if (rows.isEmpty()) {
insertPairTable(new PairTable<Long, Long>(Constants.DB_TABLE_GROUPS_GROUPTYPES, groupTypeCode, groupCode));
} else {
@SuppressWarnings({ "unchecked", "rawtypes" })
PairTable<Integer, Integer> prev = new PairTable(Constants.DB_TABLE_GROUPS_GROUPTYPES, rows.get(0).getValue("grpTypCod"), rows.get(0).getValue("grpCod"));
@SuppressWarnings({ "unchecked", "rawtypes" })
PairTable<Integer, Integer> current = new PairTable(Constants.DB_TABLE_GROUPS_GROUPTYPES, groupTypeCode, groupCode);
updatePairTable(prev, current);
}
@ -1375,7 +1378,9 @@ public class DataBaseHelper {
insertPairTable(new PairTable<Long, Long>(Constants.DB_TABLE_GROUPS_GROUPTYPES, groupTypeCode[0], groupCode));
} else {
@SuppressWarnings({ "rawtypes", "unchecked" })
PairTable<Integer, Integer> prev = new PairTable(Constants.DB_TABLE_GROUPS_GROUPTYPES, rows.get(0).getValue("grpTypCod"), rows.get(0).getValue("grpCod"));
@SuppressWarnings({ "rawtypes", "unchecked" })
PairTable<Integer, Integer> current = new PairTable(Constants.DB_TABLE_GROUPS_GROUPTYPES, groupTypeCode[0], groupCode);
updatePairTable(prev, current);
@ -1387,6 +1392,7 @@ public class DataBaseHelper {
return false;
}
@SuppressWarnings("unused")
private <T> boolean updateRelationship(Pair<String, String> tables, Pair<String, String> idsTables, String relationTable, Pair<String, T> remainField, Pair<String, T> changedField) {
@ -1413,6 +1419,7 @@ public class DataBaseHelper {
/**
* Updates an existing group type
*/
@SuppressWarnings("unused")
private boolean updateGroupType(GroupType prv, GroupType current) {
List<Entity> rows = db.getEntityList(Constants.DB_TABLE_GROUP_TYPES, "id=" + prv.getId());
boolean returnValue = true;
@ -1803,14 +1810,16 @@ public class DataBaseHelper {
* Begin a database transaction
*/
public void beginTransaction() {
db.getDB().execSQL("BEGIN;");
//db.getDB().execSQL("BEGIN;");
db.startTransaction();
}
/**
* End a database transaction
*/
public void endTransaction() {
db.getDB().execSQL("END;");
//db.getDB().execSQL("END;");
db.endTransaction();
}
/**