Examples of AnnotationSessionFactoryBean


Examples of org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean

    public void setUp() throws Exception {
        dataSource = new DriverManagerDataSource("jdbc:h2:mem:hibernate;DB_CLOSE_DELAY=-1", "sa", "sa");

        System.setProperty("hibernate.dialect", H2Dialect.class.getName());
        System.setProperty("hibernate.hbm2ddl.auto", "create-drop");
        AnnotationSessionFactoryBean sessionFactory = new AnnotationSessionFactoryBean();
        sessionFactory.setDataSource(dataSource);
        sessionFactory.setAnnotatedClasses(new Class[] {PhotoSpot.class});
        sessionFactory.afterPropertiesSet();

        repo.hibernate = new HibernateTemplate(sessionFactory.getObject());
    }
View Full Code Here

Examples of org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean

        } catch (ClassNotFoundException e) {
            throw new RuntimeException("Cannot load specified JDBC driver: " + jdbcDriver, e);
        }
        DriverManagerDataSource dataSource=new DriverManagerDataSource(jdbcConnection, jdbcUser, jdbcPassword);

        AnnotationSessionFactoryBean sessionFactoryBean = new AnnotationSessionFactoryBean();
        sessionFactoryBean.setDataSource(dataSource);
        Properties config = new Properties();
        config.setProperty("hibernate.dialect", hibernateDialect);
        config.setProperty("hibernate.connection.autocommit", "true");
        config.setProperty("hibernate.hbm2ddl.auto", "update");
        sessionFactoryBean.setHibernateProperties(config);

        sessionFactoryBean.setAnnotatedClasses(new Class<?>[]{WarningRecord.class});
        try {
            sessionFactoryBean.afterPropertiesSet();
        } catch (Exception e) {
            throw new RuntimeException("Could not set up database connection", e);
        }
        hibernateTemplate = new HibernateTemplate((SessionFactory) sessionFactoryBean.getObject());
    }
View Full Code Here

Examples of org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean

        } catch (ClassNotFoundException e) {
            throw new RuntimeException("Cannot load specified JDBC driver: " + jdbcDriver, e);
        }
        DriverManagerDataSource dataSource=new DriverManagerDataSource(jdbcConnection, jdbcUser, jdbcPassword);

        AnnotationSessionFactoryBean sessionFactoryBean = new AnnotationSessionFactoryBean();
        sessionFactoryBean.setDataSource(dataSource);
        Properties config = new Properties();
        config.setProperty("hibernate.dialect", hibernateDialect);
        config.setProperty("hibernate.connection.autocommit", "true");
        config.setProperty("hibernate.hbm2ddl.auto", "update");
        sessionFactoryBean.setHibernateProperties(config);

        sessionFactoryBean.setAnnotatedClasses(new Class<?>[]{WarningRecord.class});
        try {
            sessionFactoryBean.afterPropertiesSet();
        } catch (Exception e) {
            throw new RuntimeException("Could not set up database connection", e);
        }
        hibernateTemplate = new HibernateTemplate((SessionFactory) sessionFactoryBean.getObject());
    }
View Full Code Here

Examples of org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean

public class AppConfigWithoutComponentScan
{
    @Bean
    public SessionFactory sessionFactory() throws Exception
    {
        AnnotationSessionFactoryBean bean = new AnnotationSessionFactoryBean();
        bean.setDataSource(dataSource());
        bean.setPackagesToScan(new String[] {"org.springframework.issues"});
        bean.setHibernateProperties(hibernateProps());
        bean.afterPropertiesSet();
        return bean.getObject();
    }
View Full Code Here

Examples of org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean

public class AppConfigWithComponentScan
{
    @Bean
    public SessionFactory sessionFactory() throws Exception
    {
        AnnotationSessionFactoryBean bean = new AnnotationSessionFactoryBean();
        bean.setDataSource(dataSource());
        bean.setPackagesToScan(new String[] {"org.springframework.issues"});
        bean.setHibernateProperties(hibernateProps());
        bean.afterPropertiesSet();
        return bean.getObject();
    }
View Full Code Here

Examples of org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean

    }

    @Bean
    public AnnotationSessionFactoryBean getSessionFactory()
    {
        AnnotationSessionFactoryBean asfb = new AnnotationSessionFactoryBean();
        asfb.setDataSource(getDataSource());
        asfb.setHibernateProperties(getHibernateProperties());
        String prefixTable = environment.getProperty("joomladb.prefixtable");
        if (StringUtils.isEmpty(prefixTable)) {
            throw new IllegalStateException("Please provide joomladb.prefixtable");
        }
        asfb.setNamingStrategy(new CustomNamingStrategy(prefixTable));
        List<Class> classes = new ArrayList<Class>();
        classes.add(com.castronu.joomlajavaapi.domain.Category.class);
        classes.add(Content.class);
        classes.add(Menu.class);
        asfb.setAnnotatedClasses((classes.toArray(new Class[classes.size()])));
        return asfb;
    }
View Full Code Here

Examples of org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean

  public AnnotationSessionFactoryBean sessionFactoryBean() {
    Properties props = new Properties();
    props.put("hibernate.dialect", H2Dialect.class.getName());
    props.put("hibernate.format_sql", "true");

    AnnotationSessionFactoryBean bean = new AnnotationSessionFactoryBean();
    bean.setAnnotatedClasses(new Class[]{Item.class, Order.class});   
    bean.setHibernateProperties(props);
    bean.setDataSource(this.dataSource);
    bean.setSchemaUpdate(true);
    return bean;
  }
View Full Code Here

Examples of org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean

       
        props.put("hibernate.cache.region.factory_class", "net.sf.ehcache.hibernate.EhCacheRegionFactory");
        props.put("hibernate.cache.use_second_level_cache","true");
        props.put("hibernate.cache.use_query_cache", "false");
       
        AnnotationSessionFactoryBean bean = new AnnotationSessionFactoryBean();
        bean.setAnnotatedClasses(new Class[]{Story.class, Task.class, User.class,
                Area.class, Theme.class, Epic.class, Attribute.class,
                AttributeOption.class, LoginTableCreator.class, SchemaVersion.class, Note.class});
        bean.setHibernateProperties(props);
        bean.setDataSource(this.dataSource);
        bean.setSchemaUpdate(true);

        return bean;
    }
View Full Code Here

Examples of org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean

        super();
    }

    @Bean
    public AnnotationSessionFactoryBean sessionFactory() {
        final AnnotationSessionFactoryBean sessionFactory = new AnnotationSessionFactoryBean();
        sessionFactory.setDataSource(dataSource());
        sessionFactory.setPackagesToScan(new String[] { "org.baeldung.persistence.model" });
        sessionFactory.setHibernateProperties(hibernateProperties());

        return sessionFactory;
    }
View Full Code Here

Examples of org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean

    transactionManager.rollback(transactionStatus);
  }

  private SessionFactory createTestSessionFactory() throws Exception {
    // create a FactoryBean to help create a Hibernate SessionFactory
    AnnotationSessionFactoryBean factoryBean = new AnnotationSessionFactoryBean();
    factoryBean.setDataSource(createTestDataSource());
   
    //TODO 35: Add annotated classes

    factoryBean.setHibernateProperties(createHibernateProperties());
    // initialize according to the Spring InitializingBean contract
    factoryBean.afterPropertiesSet();
    // get the created session factory
    return (SessionFactory) factoryBean.getObject();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.