Ready! :D

This commit is contained in:
Acrobot 2012-11-03 20:40:16 +01:00
parent b1528ddc6f
commit df0de0ab44
3 changed files with 13 additions and 8 deletions

View File

@ -33,8 +33,6 @@ public class Database {
}
/**
* @Deprecated - Not ready yet
*
* Creates a table from a given class
*
* @param clazz Class with fields

View File

@ -47,17 +47,17 @@ public class EntityParser {
* @return SQL type
*/
public static String convertToSQL(Field field) {
String sqlType = "";
String sqlType = field.getName();
Class<?> type = field.getType();
if (type.isAssignableFrom(boolean.class)) {
sqlType += "BOOLEAN";
sqlType += " BOOLEAN";
} else if (type.isAssignableFrom(int.class)) {
sqlType += "INTEGER";
sqlType += " INTEGER";
} else if (type.isAssignableFrom(double.class) || type.isAssignableFrom(float.class)) {
sqlType += "REAL";
sqlType += " REAL";
} else {
sqlType += "TEXT";
sqlType += " TEXT";
}
if (field.isAnnotationPresent(Id.class)) {

View File

@ -25,6 +25,13 @@ public class Table {
this.name = name;
}
/**
* Executes a select statement
*
* @param criteria Criteria to select
* @return RowSet of results
* @throws SQLException
*/
private RowSet select(String criteria) throws SQLException {
Connection connection = database.getConnection();
@ -107,7 +114,7 @@ public class Table {
* @throws SQLException exception
*/
public void insertRow(Row row, String condition) throws SQLException {
String statement = "";
String statement;
if (condition == null || condition.isEmpty()) {
statement = String.format(INSERT_VALUES, row.stringOfValues());