Package net.sf.hibernate.cfg

Examples of net.sf.hibernate.cfg.Configuration


            if (properties.containsKey("xplanner.hibernate.mappingtransform")) {
                String transformerFileName = properties.getProperty("xplanner.hibernate.mappingtransform");
                log.info("Using Hibernate mapping transformer: " + transformerFileName);
                transformer = createTransformer(transformerFileName);
            }
            Configuration cfg = new Configuration();
            cfg.addInputStream(getMappingStream("mappings/Attribute.xml", transformer));
            cfg.addInputStream(getMappingStream("mappings/Permission.xml", transformer));
            cfg.addInputStream(getMappingStream("mappings/RoleAssociation.xml", transformer));
            cfg.addInputStream(getMappingStream("mappings/DataSample.xml", transformer));
            cfg.addInputStream(getMappingStream("mappings/Project.xml", transformer));
            cfg.addInputStream(getMappingStream("mappings/Iteration.xml", transformer));
            cfg.addInputStream(getMappingStream("mappings/UserStory.xml", transformer));
            cfg.addInputStream(getMappingStream("mappings/Task.xml", transformer));
            cfg.addInputStream(getMappingStream("mappings/TimeEntry.xml", transformer));
            cfg.addInputStream(getMappingStream("mappings/Integration.xml", transformer));
            cfg.addInputStream(getMappingStream("mappings/Note.xml", transformer));
            cfg.addInputStream(getMappingStream("mappings/Role.xml", transformer));
            cfg.addInputStream(getMappingStream("mappings/Person.xml", transformer));
            cfg.addInputStream(getMappingStream("mappings/HistoricalEvent.xml", transformer));
            cfg.addInputStream(getMappingStream("mappings/File.xml", transformer));
            cfg.addInputStream(getMappingStream("mappings/Directory.xml", transformer));
            cfg.addProperties(new XPlannerProperties().get());
            EHCacheHelper.configure(cfg);
            return cfg;
        } catch (Exception e) {
            throw new HibernateException(e);
        }
View Full Code Here


  private SessionFactory factory;

  public void configure(Properties properties) {
    try {
      Configuration config = new Configuration();

      Iterator it = properties.keySet().iterator();
      while (it.hasNext()) {
        String key = (String) it.next();
        String value = (String) properties.get(key);
        if (key.startsWith("class.")) {
          config.addClass(Resources.classForName(value));
        }
      }

      Properties props = new Properties();
      props.putAll(properties);
      config.setProperties(props);

      factory = config.buildSessionFactory();

    } catch (Exception e) {
      throw new DaoException("Error configuring Hibernate.  Cause: " + e);
    }
  }
View Full Code Here

        info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER);
        info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD);
        info.setProperty(ProxoolConstants.VERBOSE_PROPERTY, "true");
        ProxoolFacade.registerConnectionPool(url, info);

        Configuration configuration = null;
        SessionFactory sessionFactory = null;
        Session session = null;
        Properties hibernateProperties = new Properties();
        Connection connection = null;

        try {
            hibernateProperties.setProperty(Environment.DRIVER, ProxoolDriver.class.getName());
            hibernateProperties.setProperty(Environment.URL, url);

            configuration = new Configuration().addProperties(hibernateProperties);

            // create a session object to the database
            sessionFactory = configuration.buildSessionFactory();
            session = sessionFactory.openSession();
            assertNotNull("Expected a session", session);

            // Inspect the assigned connection to the session from
            // the pool.
View Full Code Here

        Properties info = new Properties();
        info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER);
        info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD);
        ProxoolFacade.registerConnectionPool(url, info);

        Configuration configuration = null;
        SessionFactory sessionFactory = null;
        Session session = null;
        Properties hibernateProperties = new Properties();
        Connection connection = null;

        try {
            hibernateProperties.setProperty(Environment.PROXOOL_EXISTING_POOL, "true");
            hibernateProperties.setProperty(Environment.PROXOOL_POOL_ALIAS, alias);

            configuration = new Configuration().addProperties(hibernateProperties);

            // create a session object to the database
            sessionFactory = configuration.buildSessionFactory();
            session = sessionFactory.openSession();
            assertNotNull("Expected a session", session);

            // Inspect the assigned connection to the session from
            // the pool.
View Full Code Here

    public void testHibernateConfiguredConnection() throws HibernateException, ProxoolException {

        String testName = "hibernateConfiguredConnection";
        String alias = testName;

        Configuration configuration = null;
        SessionFactory sessionFactory = null;
        Session session = null;
        Properties hibernateProperties = new Properties();
        Connection connection = null;

        try {
            hibernateProperties.setProperty(Environment.PROXOOL_XML, "src/java-test/org/logicalcobwebs/proxool/hibernate.xml");
            hibernateProperties.setProperty(Environment.PROXOOL_POOL_ALIAS, alias);

            configuration = new Configuration().addProperties(hibernateProperties);

            // create a session object to the database
            sessionFactory = configuration.buildSessionFactory();
            session = sessionFactory.openSession();
            assertNotNull("Expected a session", session);

            // Inspect the assigned connection to the session from
            // the pool.
View Full Code Here

          }
          catch (Exception e)
          {
        logger.error("An error occurred when we tried to close the hibernate session factory:" + e.getMessage());           
      }
          hibernateSessionFactory = new Configuration().configure().buildSessionFactory();
          logger.info("Opened:" + hibernateSessionFactory);
    }
    catch (Exception e)
    {
      logger.error("An error occurred when we tried to restore the hibernate session factory:" + e.getMessage(), e);
View Full Code Here

         
          try
          {
          logger.error("\n\nRestoring the session factory....");
            //sessionFactory.close();
          sessionFactory = new Configuration().configure().buildSessionFactory();
         
          InfoglueDefaultHibernateConfigurationProvider configurationProvider = new InfoglueDefaultHibernateConfigurationProvider();
              configurationProvider.setSessionFactory(sessionFactory);
     
              Map args = new HashMap();
View Full Code Here

public class MyRecordDAOHibernate implements MyRecordDAO {
    private static SessionFactory sessionFactory = null;

    public MyRecordDAOHibernate() {
        Configuration cfg = null;
        try {
            cfg = new Configuration().addClass(MyRecord.class);
        } catch (MappingException e) {
            e.printStackTrace();
        }

        try {
            sessionFactory = cfg.buildSessionFactory();
        } catch (HibernateException e) {
            e.printStackTrace();
        }
    }
View Full Code Here

TOP

Related Classes of 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.