* @copyright OPEN CASCADE 2012
*/
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.Statement;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
-import org.hibernate.jdbc.Work;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
-import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.apache.log4j.Logger;
// private static String CONFIG_FILE = "/hibernate.cfg.xml";
private static SessionFactory mySessionFactory = null;
- protected class CreateTables implements Work {
-// -----------------------------------------------
- protected Statement request;
-
- public void execute(Connection connex) throws SQLException
- {
- request = connex.createStatement();
-
-// Last identifier of Any objects
- String create = "CREATE TABLE `any` (" +
- "`rid` int(10) UNSIGNED NOT NULL," +
- "`version` tinytext NOT NULL," +
- "PRIMARY KEY (`rid`)" +
- ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
- request.execute(create);
-
-// Relation from entities
- create = "CREATE TABLE `relation` (" +
- "`rid` int(10) UNSIGNED NOT NULL," +
- "`name` tinytext NOT NULL," +
- "`owner` int(10) NOT NULL," +
- "`refer` int(10) NOT NULL," +
- "PRIMARY KEY (`rid`)" +
- ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
- request.execute(create);
-
-// Attribute objects
- create = "CREATE TABLE `attribute` (" +
- "`rid` int(10) UNSIGNED NOT NULL auto_increment," +
- "`type` tinytext NOT NULL," +
- "`owner` int(10) NOT NULL," +
- "`value` int(10) NOT NULL," +
- "PRIMARY KEY (`rid`)" +
- ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
- request.execute(create);
-
-// Java String objects
- create = "CREATE TABLE `text` (" +
- "`rid` int(10) UNSIGNED NOT NULL auto_increment," +
- "`value` longtext NOT NULL," +
- "PRIMARY KEY (`rid`)" +
- ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
- request.execute(create);
-
-// User and role objects
- create = "CREATE TABLE `user` (" +
- "`rid` int(10) UNSIGNED NOT NULL auto_increment," +
- "`username` varchar(32) NOT NULL," +
- "`password` varchar(32)," +
- "`first` tinytext NOT NULL," +
- "`last` tinytext NOT NULL," +
- "`display` tinytext," +
- "`email` tinytext," +
- "`organid` tinytext," +
- "PRIMARY KEY (`rid`)" +
- ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
- request.execute(create);
-
- create = "CREATE TABLE `role` (" +
- "`username` varchar(32) NOT NULL," +
- "`role` varchar(32) NOT NULL," +
- "PRIMARY KEY (`username`)" +
- ") ENGINE=MyISAM DEFAULT CHARSET=latin1";
- request.execute(create);
- }
- }
-
protected final static Logger logger = Logger.getLogger(Database.class);
// ==============================================================================================================================