mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-09-27 14:13:05 +02:00
Ready! :D
This commit is contained in:
parent
b1528ddc6f
commit
df0de0ab44
@ -33,8 +33,6 @@ public class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Deprecated - Not ready yet
|
|
||||||
*
|
|
||||||
* Creates a table from a given class
|
* Creates a table from a given class
|
||||||
*
|
*
|
||||||
* @param clazz Class with fields
|
* @param clazz Class with fields
|
||||||
|
@ -47,17 +47,17 @@ public class EntityParser {
|
|||||||
* @return SQL type
|
* @return SQL type
|
||||||
*/
|
*/
|
||||||
public static String convertToSQL(Field field) {
|
public static String convertToSQL(Field field) {
|
||||||
String sqlType = "";
|
String sqlType = field.getName();
|
||||||
Class<?> type = field.getType();
|
Class<?> type = field.getType();
|
||||||
|
|
||||||
if (type.isAssignableFrom(boolean.class)) {
|
if (type.isAssignableFrom(boolean.class)) {
|
||||||
sqlType += "BOOLEAN";
|
sqlType += " BOOLEAN";
|
||||||
} else if (type.isAssignableFrom(int.class)) {
|
} else if (type.isAssignableFrom(int.class)) {
|
||||||
sqlType += "INTEGER";
|
sqlType += " INTEGER";
|
||||||
} else if (type.isAssignableFrom(double.class) || type.isAssignableFrom(float.class)) {
|
} else if (type.isAssignableFrom(double.class) || type.isAssignableFrom(float.class)) {
|
||||||
sqlType += "REAL";
|
sqlType += " REAL";
|
||||||
} else {
|
} else {
|
||||||
sqlType += "TEXT";
|
sqlType += " TEXT";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field.isAnnotationPresent(Id.class)) {
|
if (field.isAnnotationPresent(Id.class)) {
|
||||||
|
@ -25,6 +25,13 @@ public class Table {
|
|||||||
this.name = name;
|
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 {
|
private RowSet select(String criteria) throws SQLException {
|
||||||
Connection connection = database.getConnection();
|
Connection connection = database.getConnection();
|
||||||
|
|
||||||
@ -107,7 +114,7 @@ public class Table {
|
|||||||
* @throws SQLException exception
|
* @throws SQLException exception
|
||||||
*/
|
*/
|
||||||
public void insertRow(Row row, String condition) throws SQLException {
|
public void insertRow(Row row, String condition) throws SQLException {
|
||||||
String statement = "";
|
String statement;
|
||||||
|
|
||||||
if (condition == null || condition.isEmpty()) {
|
if (condition == null || condition.isEmpty()) {
|
||||||
statement = String.format(INSERT_VALUES, row.stringOfValues());
|
statement = String.format(INSERT_VALUES, row.stringOfValues());
|
||||||
|
Loading…
Reference in New Issue
Block a user