package org.splat.dal.dao.kernel;
+
/**
*
* @author Daniel Brunier-Coulin
*/
import org.hibernate.Session;
-import org.hibernate.SessionFactory;
+import org.splat.service.technical.IndexService;
+import org.splat.service.technical.RepositoryService;
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;
-
-public abstract class Database implements ApplicationContextAware {
+public abstract class Database extends HibernateDaoSupport implements
+ ApplicationContextAware {
/**
* The ApplicationContext.
/**
* Spring will call this method for initialize the applicationContext.
- * @param ctx the application context
- * @throws BeansException the BeanException
+ *
+ * @param ctx
+ * the application context
+ * @throws BeansException
+ * the BeanException
*/
- public void setApplicationContext(final ApplicationContext ctx) throws BeansException {
+ public void setApplicationContext(final ApplicationContext ctx)
+ throws BeansException {
_context = ctx;
}
/**
* Static for getting the context.
+ *
* @return ApplicationContext the application context
*/
public static ApplicationContext getContext() {
return _context;
}
-
-// private static String CONFIG_FILE = "/hibernate.cfg.xml";
- private static SessionFactory mySessionFactory = null;
- protected final static Logger logger = Logger.getLogger(Database.class);
-
-// ==============================================================================================================================
-// Public services
-// ==============================================================================================================================
+ // private static String CONFIG_FILE = "/hibernate.cfg.xml";
+ protected final static Logger logger = Logger.getLogger(Database.class);
- public static Session getSession () {
-// -----------------------------------
- return getInstance().getCurrentSession();
- }
-
-// ==============================================================================================================================
-// Protected services
-// ==============================================================================================================================
+ // ==============================================================================================================================
+ // Protected services
+ // ==============================================================================================================================
- protected String getSchemaVersion () {
-// ------------------------------------
- return null;//TODO: Get schema version into specific object/table: getIDPool().getSchemaVersion();
- }
+ protected String getSchemaVersion() {
+ // ------------------------------------
+ return null;// TODO: Get schema version into specific object/table: getIDPool().getSchemaVersion();
+ }
- protected void setSchemaVersion (String version) {
-// ------------------------------------------------
-//TODO: Set schema version into specific object/table: myIDpool = new IDPool(version);
-// getSession().save(myIDpool);
- }
+ protected void setSchemaVersion(String version) {
+ // ------------------------------------------------
+ // TODO: Set schema version into specific object/table: myIDpool = new IDPool(version);
+ // getSession().save(myIDpool);
+ }
-// ==============================================================================================================================
-// Private services
-// ==============================================================================================================================
-
- private static SessionFactory getInstance () {
-// --------------------------------------------
- if (mySessionFactory == null) {
-// org.hibernate.cfg.Configuration cfg = new org.hibernate.cfg.Configuration();
- try {
- mySessionFactory = getContext().getBean(SessionFactory.class);
-// cfg.configure(); // The configuration file (hibernate.cfg.xml)) is supposed to be on the classpath
-// mySessionFactory = cfg.buildSessionFactory();
- }
- catch (Exception error) {
- logger.fatal("Could not initialize the Hibernate configuration, reason:", error);
- }
- }
- return mySessionFactory;
- }
+ // ==============================================================================================================================
+ // Private services
+ // ==============================================================================================================================
+//{
+// if (myDB == null) {
+// myDB = new Database();
+// }
+// return myDB;
+// }
}
\ No newline at end of file