Database stuffffff

This commit is contained in:
Acrobot 2012-10-28 23:54:06 +01:00
parent aed6eff863
commit efc8a32f98
2 changed files with 23 additions and 1 deletions

View File

@ -1,5 +1,6 @@
package com.Acrobot.Breeze.Database;
import javax.persistence.Entity;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
@ -31,6 +32,27 @@ public class Database {
return new Table(this, name);
}
/**
* Creates a table from a given class
*
* @param clazz Class with fields
* @return If table was succesfully created
*/
public boolean createFromClass(Class clazz) {
if (!clazz.isAnnotationPresent(Entity.class) || !clazz.isAnnotationPresent(javax.persistence.Table.class)) {
return false;
}
String tableName = ((javax.persistence.Table) clazz.getAnnotation(javax.persistence.Table.class)).name();
Table table = getTable(tableName);
EntityParser parser = new EntityParser(clazz);
//TODO Finish this
return true;
}
/**
* @return Connection to the database
* @throws SQLException exception

View File

@ -46,6 +46,6 @@ public class EntityParser {
* @return SQL type
*/
public String convertToSQL(Field field) {
return null;
return null; //TODO Finish this
}
}