Add Sqlite delete DTO
This commit is contained in:
@@ -102,6 +102,7 @@ public abstract class AbstractDhRepo<TDTO extends IBaseDTO>
|
||||
|
||||
// high level DB //
|
||||
|
||||
public TDTO get(TDTO dto) { return this.getByPrimaryKey(dto.getPrimaryKeyString()); }
|
||||
public TDTO getByPrimaryKey(String primaryKey)
|
||||
{
|
||||
TDTO dto = null;
|
||||
@@ -133,6 +134,8 @@ public abstract class AbstractDhRepo<TDTO extends IBaseDTO>
|
||||
private void insert(TDTO dto) { this.queryNoResult(this.createInsertSql(dto)); }
|
||||
private void update(TDTO dto) { this.queryNoResult(this.createUpdateSql(dto)); }
|
||||
|
||||
public void delete(TDTO dto) { this.queryNoResult(this.createDeleteSql(dto)); }
|
||||
|
||||
|
||||
|
||||
// low level DB //
|
||||
@@ -208,4 +211,6 @@ public abstract class AbstractDhRepo<TDTO extends IBaseDTO>
|
||||
public abstract String createInsertSql(TDTO dto);
|
||||
public abstract String createUpdateSql(TDTO dto);
|
||||
|
||||
public abstract String createDeleteSql(TDTO dto);
|
||||
|
||||
}
|
||||
|
||||
@@ -94,4 +94,10 @@ public class TestDataRepo extends AbstractDhRepo<TestDto>
|
||||
"WHERE Id = "+id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createDeleteSql(TestDto dto)
|
||||
{
|
||||
return "DELETE FROM "+this.getTableName()+" WHERE Id = '"+dto.id+"'";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,11 +19,6 @@
|
||||
|
||||
package tests;
|
||||
|
||||
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGenerationStep;
|
||||
import com.seibel.distanthorizons.core.file.fullDatafile.FullDataMetaFile;
|
||||
import com.seibel.distanthorizons.core.file.metaData.BaseMetaData;
|
||||
import com.seibel.distanthorizons.core.pos.DhSectionPos;
|
||||
import com.seibel.distanthorizons.core.sql.FullMetaDataRepo;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import testItems.sql.TestDataRepo;
|
||||
@@ -83,6 +78,14 @@ public class DhRepoSqliteTest
|
||||
Assert.assertEquals("get/insert failed, not equal", updateMetaFile.id, getDto.id);
|
||||
Assert.assertEquals("get/insert failed, not equal", updateMetaFile.value, getDto.value);
|
||||
|
||||
|
||||
// delete
|
||||
testDataRepo.delete(updateMetaFile);
|
||||
|
||||
// get
|
||||
getDto = testDataRepo.getByPrimaryKey("0");
|
||||
Assert.assertNull("delete failed, not null returned", getDto);
|
||||
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user