@Bean public SessionFactory sessionFactory() throws Exception { LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean(); factoryBean.setDataSource(dataSource()); factoryBean.setMappingLocations(new ClassPathResource("/org/springframework/batch/item/database/Foo.hbm.xml", getClass())); factoryBean.afterPropertiesSet(); return factoryBean.getObject(); } }
@Bean public SessionFactory sessionFactory() throws Exception { LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean(); factoryBean.setDataSource(dataSource()); factoryBean.setMappingLocations(new ClassPathResource("/org/springframework/batch/item/database/Foo.hbm.xml", getClass())); factoryBean.afterPropertiesSet(); return factoryBean.getObject(); } }
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(); }
@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(); }
private void initializeItemReader(HibernateCursorItemReader<?> reader, String hsqlQuery) throws Exception { LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean(); factoryBean.setDataSource(dataSource); factoryBean.setMappingLocations(new Resource[] { new ClassPathResource( "Foo.hbm.xml", getClass()) }); factoryBean.afterPropertiesSet(); SessionFactory sessionFactory = factoryBean .getObject(); reader.setQueryString(hsqlQuery); reader.setSessionFactory(sessionFactory); reader.afterPropertiesSet(); reader.setSaveState(true); reader.open(new ExecutionContext()); }
@Override protected ItemReader<Foo> createItemReader() throws Exception { LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean(); factoryBean.setDataSource(dataSource); factoryBean.setMappingLocations(new ClassPathResource("Foo.hbm.xml", getClass())); customizeSessionFactory(factoryBean); factoryBean.afterPropertiesSet(); SessionFactory sessionFactory = factoryBean.getObject(); HibernateCursorItemReader<Foo> hibernateReader = new HibernateCursorItemReader<>(); setQuery(hibernateReader); hibernateReader.setSessionFactory(sessionFactory); hibernateReader.setUseStatelessSession(isUseStatelessSession()); hibernateReader.afterPropertiesSet(); hibernateReader.setSaveState(true); return hibernateReader; }
@Override protected ItemReader<Foo> createItemReader() throws Exception { LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean(); factoryBean.setDataSource(dataSource); factoryBean.setMappingLocations(new ClassPathResource("Foo.hbm.xml", getClass())); customizeSessionFactory(factoryBean); factoryBean.afterPropertiesSet(); SessionFactory sessionFactory = factoryBean.getObject(); HibernatePagingItemReader<Foo> hibernateReader = new HibernatePagingItemReader<>(); setQuery(hibernateReader); hibernateReader.setPageSize(2); hibernateReader.setSessionFactory(sessionFactory); hibernateReader.setUseStatelessSession(isUseStatelessSession()); hibernateReader.afterPropertiesSet(); hibernateReader.setSaveState(true); return hibernateReader; }
@Override public void afterPropertiesSet() throws IOException { // Add any properties from HibernateConfig to any values configured using hibernateProperties if (hibernateConfig != null) { getHibernateProperties().putAll(hibernateConfig.getHibernateProperties()); } super.afterPropertiesSet(); } }
private static LocalSessionFactoryBean generateSessionFactoryBean(String[] basePackage, DataSource dataSource, Properties hibernateProperties) { LocalSessionFactoryBean localSessionFactoryBean = new LocalSessionFactoryBean(); localSessionFactoryBean.setDataSource(dataSource); localSessionFactoryBean.setPackagesToScan(basePackage); localSessionFactoryBean.setHibernateProperties(hibernateProperties); // Added the below line localSessionFactoryBean.afterPropertiesSet(); return localSessionFactoryBean; }
bean.setPackagesToScan(getBasePackage()); try { bean.afterPropertiesSet();
private SessionFactory getSessionFactory(DataSource dataSource) throws Exception { org.springframework.orm.hibernate5.LocalSessionFactoryBean factory = new org.springframework.orm.hibernate5.LocalSessionFactoryBean(); factory.setDataSource(dataSource); factory.setMappingLocations( new ClassPathResource("org/springframework/webflow/persistence/TestBean.hbm.xml"), new ClassPathResource("org/springframework/webflow/persistence/TestAddress.hbm.xml")); factory.afterPropertiesSet(); return factory.getObject(); }
private SessionFactory getSessionFactory(DataSource dataSource) throws Exception { LocalSessionFactoryBean factory = new LocalSessionFactoryBean(); factory.setDataSource(dataSource); factory.setMappingLocations( new ClassPathResource("org/springframework/webflow/persistence/TestBean.hbm.xml"), new ClassPathResource("org/springframework/webflow/persistence/TestAddress.hbm.xml")); factory.afterPropertiesSet(); return factory.getObject(); }
factoryBean.afterPropertiesSet(); log.info("SessionFactory Bean을 생성했습니다!!!");
private LocalSessionFactoryBean sfBean(String packageName, String dialect) { LocalSessionFactoryBean sfBean = new LocalSessionFactoryBean(); try { sfBean.setPackagesToScan(packageName); sfBean.setHibernateProperties(hibernateProperties(dialect)); sfBean.afterPropertiesSet(); } catch (IOException e) { throw new InvocationException(e); } return sfBean; }
private LocalSessionFactoryBean sfBean(String packageName, String dialect) { LocalSessionFactoryBean sfBean = new LocalSessionFactoryBean(); try { sfBean.setPackagesToScan(packageName); sfBean.setHibernateProperties(hibernateProperties(dialect)); sfBean.afterPropertiesSet(); } catch (IOException e) { throw new InvocationException(e); } return sfBean; }