Package com.dotcms.repackage.net.sf.hibernate.cfg

Examples of com.dotcms.repackage.net.sf.hibernate.cfg.Configuration


      ##
      ##  USE THE FILE hibernate.cfg.xml to point to mapping files
      ##
      #################################
      */
      Configuration cfg = new Configuration().configure();

      if (DbConnectionFactory.isMySql()) {
        //http://jira.dotmarketing.net/browse/DOTCMS-4937
        cfg.setNamingStrategy(new LowercaseNamingStrategy());
        cfg.addResource("com/dotmarketing/beans/DotCMSId.hbm.xml");
        cfg.addResource("com/dotmarketing/beans/DotCMSId_NOSQLGEN.hbm.xml");
        getPluginsHBM("Id",cfg);
        cfg.setProperty("hibernate.dialect", "com.dotcms.repackage.net.sf.hibernate.dialect.MySQLDialect");
      } else if (DbConnectionFactory.isPostgres()) {
        cfg.addResource("com/dotmarketing/beans/DotCMSSeq.hbm.xml");
        cfg.addResource("com/dotmarketing/beans/DotCMSSeq_NOSQLGEN.hbm.xml");
        getPluginsHBM("Seq",cfg);
        cfg.setProperty("hibernate.dialect", "com.dotcms.repackage.net.sf.hibernate.dialect.PostgreSQLDialect");
      } else if (DbConnectionFactory.isMsSql()) {
        cfg.addResource("com/dotmarketing/beans/DotCMSId.hbm.xml");
        cfg.addResource("com/dotmarketing/beans/DotCMSId_NOSQLGEN.hbm.xml");
        getPluginsHBM("Id",cfg);
        cfg.setProperty("hibernate.dialect", "com.dotcms.repackage.net.sf.hibernate.dialect.SQLServerDialect");
      } else if (DbConnectionFactory.isOracle()) {
        cfg.addResource("com/dotmarketing/beans/DotCMSSeq.hbm.xml");
        cfg.addResource("com/dotmarketing/beans/DotCMSSeq_NOSQLGEN.hbm.xml");
        getPluginsHBM("Seq",cfg);
        cfg.setProperty("hibernate.dialect", "com.dotcms.repackage.net.sf.hibernate.dialect.OracleDialect");
      } else if (DbConnectionFactory.isH2()) {
          cfg.addResource("com/dotmarketing/beans/DotCMSId.hbm.xml");
                cfg.addResource("com/dotmarketing/beans/DotCMSId_NOSQLGEN.hbm.xml");
                getPluginsHBM("Id",cfg);
                cfg.setProperty("hibernate.dialect", "com.dotcms.repackage.net.sf.hibernate.dialect.HSQLDialect");
      }

      cfg.setInterceptor(new NoDirtyFlushInterceptor());

      mappings = cfg.createMappings();
      sessionFactory = cfg.buildSessionFactory();
      dialect = cfg.getProperty("hibernate.dialect");

    }catch (Exception e) {
      throw new DotHibernateException("Unable to build Session Factory ", e);
    }
  }
View Full Code Here


       Logger.info(this, "Driver not found dialect:" + e);
       throw new BuildException("database driver not found");
    }
   
    try {
      Configuration cfg = new Configuration();
      cfg.setProperty("hibernate.dialect", dialect);
           
      if (dialect.equals("com.dotcms.repackage.net.sf.hibernate.dialect.MySQLDialect")){
                cfg.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver");
        cfg.addResource("com/dotmarketing/beans/DotCMSId.hbm.xml");
      }else if (dialect.equals("com.dotcms.repackage.net.sf.hibernate.dialect.SybaseDialect")){
        cfg.addResource("com/dotmarketing/beans/DotCMSId.hbm.xml");
                cfg.setProperty("hibernate.connection.driver_class", "net.sourceforge.jtds.jdbc.Driver");
      }else if(dialect.equals("com.dotcms.repackage.net.sf.hibernate.dialect.OracleDialect")){
        cfg.addResource("com/dotmarketing/beans/DotCMSSeq.hbm.xml");
                cfg.setProperty("hibernate.connection.driver_class", "oracle.jdbc.driver.OracleDriver");
      }else if(dialect.equals("com.dotcms.repackage.net.sf.hibernate.dialect.PostgreSQLDialect")) {
        cfg.addResource("com/dotmarketing/beans/DotCMSSeq.hbm.xml");
                cfg.setProperty("hibernate.connection.driver_class", "org.postgresql.Driver");
      }else if(dialect.equals("com.dotcms.repackage.net.sf.hibernate.dialect.HSQLDialect")) {
          cfg.setProperty("hibernate.connection.driver_class", "org.h2.Driver");
          cfg.addResource("com/dotmarketing/beans/DotCMSId.hbm.xml");
      }

            SchemaExport sexp = new SchemaExport(cfg);
      sexp.setDelimiter(";");
      //DOTCMS-2915
View Full Code Here

  public void init() {
    try {
      ClassLoader classLoader = getClass().getClassLoader();

      Configuration cfg = new Configuration();

      InputStream is =
        classLoader.getResourceAsStream("META-INF/sample-hbm.xml");

      if (is != null) {
        cfg = cfg.addInputStream(is);

        is.close();
      }

      cfg.setProperty(
        "hibernate.connection.datasource",
        "jdbc/SamplePool");

      cfg.setProperty(
        "hibernate.statement_cache.size",
        "0");

      cfg.setProperty(
        "hibernate.dialect",
        "com.liferay.util.dao.hibernate.DynamicDialect");

      cfg.setProperty(
        "hibernate.jdbc.batch_size",
        "0");

      cfg.setProperty(
        "hibernate.jdbc.use_scrollable_resultset",
        "true");

      cfg.setProperty(
        "hibernate.cglib.use_reflection_optimizer",
        "false");

      cfg.setProperty(
        "hibernate.connection.provider_class",
        "com.liferay.util.dao.hibernate.DSConnectionProvider");

      cfg.setProperty(
        "hibernate.cache.provider_class",
        "com.dotcms.repackage.net.sf.hibernate.cache.EhCacheProvider");

      cfg.setProperty(
        "hibernate.show_sql",
        "false");

      setSessionFactory(cfg.buildSessionFactory());
    }
    catch (Exception e) {
      Logger.error(this,e.getMessage(),e);
    }
  }
View Full Code Here

  public void init() {
    try {
      ClassLoader classLoader = getClass().getClassLoader();

      Configuration cfg = new Configuration();

      String[] configs = StringUtil.split(
        SystemProperties.get("hibernate.configs"));

      for (int i = 0; i < configs.length; i++) {
        try {
          InputStream is =
            classLoader.getResourceAsStream(configs[i]);

          if (is != null) {
            cfg = cfg.addInputStream(is);

            is.close();
          }
        }
        catch (Exception e) {
          Logger.error(this,e.getMessage(),e);
        }
      }

      cfg.setProperties(SystemProperties.getProperties());
      //http://jira.dotmarketing.net/browse/DOTCMS-4937
      if (DbConnectionFactory.isMySql()) {
        cfg.setNamingStrategy(new LowercaseNamingStrategy());
        Table liferayTable  = cfg.getClassMapping(com.liferay.portal.ejb.CompanyHBM.class).getTable();
        liferayTable.setName("company");
        liferayTable  = cfg.getClassMapping(com.liferay.portal.ejb.AddressHBM.class).getTable();
        liferayTable.setName("address");
        liferayTable  = cfg.getClassMapping(com.liferay.portal.ejb.ImageHBM.class).getTable();
        liferayTable.setName("image");
        liferayTable  = cfg.getClassMapping(com.liferay.portal.ejb.PasswordTrackerHBM.class).getTable();
        liferayTable.setName("passwordtracker");
        liferayTable  = cfg.getClassMapping(com.liferay.portal.ejb.PortletHBM.class).getTable();
        liferayTable.setName("portlet");
        liferayTable  = cfg.getClassMapping(com.liferay.portal.ejb.PortletPreferencesHBM.class).getTable();
        liferayTable.setName("portletpreferences");
        liferayTable  = cfg.getClassMapping(com.liferay.portal.ejb.ReleaseHBM.class).getTable();
        liferayTable.setName("release_");
        liferayTable  = cfg.getClassMapping(com.liferay.portal.ejb.UserHBM.class).getTable();
        liferayTable.setName("user_");
        liferayTable  = cfg.getClassMapping(com.liferay.portal.ejb.UserTrackerHBM.class).getTable();
        liferayTable.setName("usertracker");
        liferayTable  = cfg.getClassMapping(com.liferay.portal.ejb.UserTrackerPathHBM.class).getTable();
        liferayTable.setName("usertrackerpath");
        liferayTable  = cfg.getClassMapping(com.liferay.portlet.admin.ejb.AdminConfigHBM.class).getTable();
        liferayTable.setName("adminconfig");
        liferayTable  = cfg.getClassMapping(com.liferay.portlet.polls.ejb.PollsChoiceHBM.class).getTable();
        liferayTable.setName("pollschoice");
        liferayTable  = cfg.getClassMapping(com.liferay.portlet.polls.ejb.PollsDisplayHBM.class).getTable();
        liferayTable.setName("pollsdisplay");
        liferayTable  = cfg.getClassMapping(com.liferay.portlet.polls.ejb.PollsQuestionHBM.class).getTable();
        liferayTable.setName("pollsquestion");
        liferayTable  = cfg.getClassMapping(com.liferay.portlet.polls.ejb.PollsVoteHBM.class).getTable();
        liferayTable.setName("pollsvote");
        liferayTable  = cfg.getClassMapping(com.dotcms.repackage.com.liferay.counter.ejb.CounterHBM.class).getTable();
        liferayTable.setName("counter");
      }

      setSessionFactory(cfg.buildSessionFactory());
    }
    catch (Exception e) {
      Logger.error(this,e.getMessage(),e);
    }
  }
View Full Code Here

TOP

Related Classes of com.dotcms.repackage.net.sf.hibernate.cfg.Configuration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.