Package org.springframework.orm.hibernate4

Examples of org.springframework.orm.hibernate4.HibernateTransactionManagerTests


AbstractGenericDataSourceItemReaderIntegrationTests {

  @Override
  protected ItemReader<Foo> createItemReader() throws Exception {

    LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean();
    factoryBean.setDataSource(dataSource);
    factoryBean.setMappingLocations(new Resource[] { new ClassPathResource("Foo.hbm.xml", getClass()) });
    customizeSessionFactory(factoryBean);
    factoryBean.afterPropertiesSet();

    SessionFactory sessionFactory = factoryBean.getObject();

    HibernateCursorItemReader<Foo> hibernateReader = new HibernateCursorItemReader<Foo>();
    setQuery(hibernateReader);
    hibernateReader.setSessionFactory(sessionFactory);
    hibernateReader.setUseStatelessSession(isUseStatelessSession());
View Full Code Here


  }

  @Before
  public void setUp() throws Exception {

    LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean();
    factoryBean.setDataSource(dataSource);
    factoryBean.setMappingLocations(new Resource[] { new ClassPathResource("../Foo.hbm.xml", getClass()) });
    factoryBean.afterPropertiesSet();

    sessionFactory = factoryBean.getObject();

  }
View Full Code Here

    return reader;
  }

  private SessionFactory createSessionFactory() throws Exception {
    LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean();
    factoryBean.setDataSource(getDataSource());
    factoryBean.setMappingLocations(new Resource[] { new ClassPathResource("Foo.hbm.xml", getClass()) });
    factoryBean.afterPropertiesSet();

    return factoryBean.getObject();

  }
View Full Code Here

    return dataSource;
  }
 
  @Bean
  public LocalSessionFactoryBean sessionFactory() {
    LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean();
    sessionFactoryBean.setDataSource(dataSource());
    sessionFactoryBean.setPackagesToScan(env.getRequiredProperty(PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN));
    sessionFactoryBean.setHibernateProperties(hibProperties());
    return sessionFactoryBean;
  }
View Full Code Here

     */
    @Bean
    public SessionFactory sessionFactory() throws IOException {
        log.info("SessionFactory Bean을 생성합니다...");

        LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean();

        String[] packagenames = getMappedPackageNames();
        if (packagenames != null && packagenames.length > 0) {
            log.debug("hibernate용 entity를 scan합니다. packages=[{}]", arrayToCommaDelimitedString(packagenames));
            factoryBean.setPackagesToScan(packagenames);
        }

        // Naming strategy
        NamingStrategy ns = getNamingStrategy();
        if (ns != null)
            factoryBean.setNamingStrategy(ns);

        // Hibernate properties
        factoryBean.setHibernateProperties(hibernateProperties());
        factoryBean.setDataSource(dataSource());

        Interceptor interceptor = hibernateInterceptor();
        if (interceptor != null)
            factoryBean.setEntityInterceptor(hibernateInterceptor());

        setupSessionFactory(factoryBean);

        factoryBean.afterPropertiesSet();
        log.info("SessionFactory Bean을 생성했습니다!!!");

        return factoryBean.getObject();
    }
View Full Code Here

    }

    @Bean
    public SessionFactory sessionFactory() throws IOException {

        LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean();
        factoryBean.setPackagesToScan(getMappedPackageNames());
        factoryBean.setDataSource(dataSource());
        factoryBean.setHibernateProperties(hibernateProperties());

        factoryBean.afterPropertiesSet();

        return factoryBean.getObject();
    }
View Full Code Here

    dataSource.setPassword("");
    dataSource.setDefaultAutoCommit(false);
    dataSource.setFilters("log4j");

    /*init sessionFactory*/
    LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean();
    factoryBean.setDataSource(dataSource);

    Properties prop = new Properties();
    prop.put("hibernate.show_sql", "true");
    //prop.put("hibernate.format_sql", "true");
    prop.put("hibernate.hbm2ddl.auto", "create");
    prop.put("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
    factoryBean.setHibernateProperties(prop);
    factoryBean.setAnnotatedClasses(new Class<?>[]{Sample.class});

    try {
      factoryBean.afterPropertiesSet();
    } catch (IOException e) {
      e.printStackTrace();
    }
    sessionFactory = factoryBean.getObject();
  }
View Full Code Here

        super();
    }

    @Bean
    public LocalSessionFactoryBean sessionFactory() {
        final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
        sessionFactory.setDataSource(restDataSource());
        sessionFactory.setPackagesToScan(new String[] { "org.baeldung.ex.mappingexception.cause1.persistence.model" });
        sessionFactory.setHibernateProperties(hibernateProperties());

        return sessionFactory;
    }
View Full Code Here

        super();
    }

    @Bean
    public LocalSessionFactoryBean sessionFactory() {
        final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
        sessionFactory.setDataSource(restDataSource());
        sessionFactory.setHibernateProperties(hibernateProperties());

        // sessionFactory.setPackagesToScan(new String[] { "org.baeldung.ex.mappingexception.cause2.persistence.model" });
        sessionFactory.setAnnotatedClasses(new Class[] { Foo.class });

        return sessionFactory;
    }
View Full Code Here

        super();
    }

    @Bean
    public LocalSessionFactoryBean sessionFactory() {
        final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
        sessionFactory.setDataSource(restDataSource());
        sessionFactory.setHibernateProperties(hibernateProperties());

        // sessionFactory.setPackagesToScan(new String[] { "org.baeldung.ex.mappingexception.cause2.persistence.model" });
        // sessionFactory.setAnnotatedClasses(new Class[] { Foo.class });

        return sessionFactory;
View Full Code Here

TOP

Related Classes of org.springframework.orm.hibernate4.HibernateTransactionManagerTests

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.