当前位置: 首页>>代码示例>>Java>>正文


Java LocalSessionFactoryBuilder类代码示例

本文整理汇总了Java中org.springframework.orm.hibernate4.LocalSessionFactoryBuilder的典型用法代码示例。如果您正苦于以下问题:Java LocalSessionFactoryBuilder类的具体用法?Java LocalSessionFactoryBuilder怎么用?Java LocalSessionFactoryBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LocalSessionFactoryBuilder类属于org.springframework.orm.hibernate4包,在下文中一共展示了LocalSessionFactoryBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSessionFactory

import org.springframework.orm.hibernate4.LocalSessionFactoryBuilder; //导入依赖的package包/类
@Autowired
@Bean(name="sessionFactory")
public SessionFactory getSessionFactory(DataSource dataSource)
{
	System.out.println("---Hibernate Properties----");
	Properties prop=new Properties();
	prop.setProperty("hibernate.hbm2ddl.auto", "update");
	prop.put("hibernate.show_sql", "true"); //optional
	prop.put("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
	System.out.println("---Hibernate Properties Created");
	
	System.out.println("---Local SessionFactory Builder Object Creation---");
	LocalSessionFactoryBuilder sessionBuilder = new LocalSessionFactoryBuilder(getH2DataSource());
	sessionBuilder.addProperties(prop);
	System.out.println("---Factory Builder Object Created---");
			
	SessionFactory sessionFactory=sessionBuilder.buildSessionFactory();
	System.out.println("Session Factory Object Created");
	return sessionFactory;
}
 
开发者ID:AakashOfficial,项目名称:Book-Management,代码行数:21,代码来源:DBConfig.java

示例2: buildSessionFactory

import org.springframework.orm.hibernate4.LocalSessionFactoryBuilder; //导入依赖的package包/类
@Override
protected SessionFactory buildSessionFactory(LocalSessionFactoryBuilder sfb) {
	List<AdditionalHibernateMappings> mappings = new ArrayList<>();
	String[] names = applicationContext.getBeanNamesForType(AdditionalHibernateMappings.class, false, false);

	try {
		for (String name : names) {
			mappings.add((AdditionalHibernateMappings) applicationContext.getBean(name));
		}

		Collections.sort(mappings);

		for (AdditionalHibernateMappings mapping : mappings) {
			mapping.processAdditionalMappings(sfb);
		}
	} catch (Exception e) {
		log.error(e.getMessage(), e);
		throw new RuntimeException(e);
	}

	AssignableUUIDGenerator.setServerConfigurationService(serverConfigurationService);
	sfb.getIdentifierGeneratorFactory().register("uuid2", AssignableUUIDGenerator.class);

	return sfb.buildSessionFactory();
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:26,代码来源:AddableSessionFactoryBean.java

示例3: getSessionFactory

import org.springframework.orm.hibernate4.LocalSessionFactoryBuilder; //导入依赖的package包/类
@Autowired
@Bean(name = "sessionFactory")
public SessionFactory getSessionFactory(DataSource dataSource)
{
	LocalSessionFactoryBuilder sessionBuilder = new LocalSessionFactoryBuilder(dataSource);
	sessionBuilder.addProperties(getHibernateProperties());
	sessionBuilder.addAnnotatedClasses(Restaurant.class, RestaurantCategory.class);
	return sessionBuilder.buildSessionFactory();
}
 
开发者ID:OpenDataCyprus,项目名称:integers,代码行数:10,代码来源:ApplicationContextConfig.java

示例4: getSessionFactory

import org.springframework.orm.hibernate4.LocalSessionFactoryBuilder; //导入依赖的package包/类
@Autowired
@Bean(name = "sessionFactory")
public SessionFactory getSessionFactory(DataSource dataSource) {

	LocalSessionFactoryBuilder sessionBuilder = new LocalSessionFactoryBuilder(dataSource);

	sessionBuilder.scanPackages("tr.org.lkd.lyk2015.camp.model");
	sessionBuilder.addProperties(this.getHibernateProperties());

	return sessionBuilder.buildSessionFactory();
}
 
开发者ID:kodgemisi-archive,项目名称:camp,代码行数:12,代码来源:RootConfig.java

示例5: getSessionFactory

import org.springframework.orm.hibernate4.LocalSessionFactoryBuilder; //导入依赖的package包/类
@Autowired
@Bean(name = "sessionFactory")
public SessionFactory getSessionFactory(DataSource ds) {
    /*
     * Setup Hibernate as ORM over the data source object by using
     * sessions: a session opens a single database connection when it is
     * created, and holds onto it until the session is closed. Every
     * object that is loaded by Hibernate from the database is associated
     * with the session.
     */
    LocalSessionFactoryBuilder sb =
        new LocalSessionFactoryBuilder(ds);

    /*
     * Configure Hibernate using the following featuers:
     *  - log SQL statements.
     *  - use Derby SQL dialect.
     *  - generate database tables from JPA annotations.
     *  - populate database tables with initial values.
     */
    Properties p = new Properties();
    p.put("hibernate.show_sql", "true");
    p.put("hibernate.dialect", "org.hibernate.dialect.DerbyDialect");
    p.put("hibernate.hbm2ddl.auto", "create");
    p.put("hibernate.hbm2ddl.import_files", "META-INF/sql/data.sql");
    sb.addProperties(p);

    /*
     * Manually add all the Entity classes to Hibernate: in addition to
     * its own "native" API, Hibernate is also an implementation of the
     * Java Persistence API (JPA) specification.
     */
    sb.addAnnotatedClasses(Contact.class);
    sb.addAnnotatedClasses(User.class);

    /* Return a session factory */
    return sb.buildSessionFactory();
}
 
开发者ID:epalrov,项目名称:address-book,代码行数:39,代码来源:ContactApplicationConfig.java

示例6: sessionFactory

import org.springframework.orm.hibernate4.LocalSessionFactoryBuilder; //导入依赖的package包/类
@Bean @PersistenceContext(type = PersistenceContextType.EXTENDED)
public SessionFactory sessionFactory() {
    LocalSessionFactoryBuilder builder = new LocalSessionFactoryBuilder(dataSource());
    builder.scanPackages("org.proflr.server.entity").addProperties(getHibernateProperties());

    return builder.buildSessionFactory();
}
 
开发者ID:proflr,项目名称:proflr-server,代码行数:8,代码来源:Application.java

示例7: getSessionFactory

import org.springframework.orm.hibernate4.LocalSessionFactoryBuilder; //导入依赖的package包/类
@Autowired
@Bean(name = "sessionFactory")
public SessionFactory getSessionFactory(DataSource dataSource) {

	LocalSessionFactoryBuilder sessionBuilder = new LocalSessionFactoryBuilder(dataSource);

	sessionBuilder.scanPackages("com.kodgemisi.web.sample.model");
	sessionBuilder.addProperties(this.getHibernateProperties());

	return sessionBuilder.buildSessionFactory();
}
 
开发者ID:kodgemisi-archive,项目名称:web-sample,代码行数:12,代码来源:RootConfig.java

示例8: sessionFactory

import org.springframework.orm.hibernate4.LocalSessionFactoryBuilder; //导入依赖的package包/类
@Bean(name = "org.sakaiproject.springframework.orm.hibernate.GlobalSessionFactory")
public SessionFactory sessionFactory() throws IOException {
    LocalSessionFactoryBuilder sfb = new LocalSessionFactoryBuilder(dataSource());
    hibernateMappings.processAdditionalMappings(sfb);
    sfb.addProperties(hibernateProperties());
    sfb.getIdentifierGeneratorFactory().register("uuid2", AssignableUUIDGenerator.class);
    return sfb.buildSessionFactory();
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:9,代码来源:AssignmentTestConfiguration.java

示例9: sessionFactory

import org.springframework.orm.hibernate4.LocalSessionFactoryBuilder; //导入依赖的package包/类
@Bean(name = "org.sakaiproject.springframework.orm.hibernate.GlobalSessionFactory")
public SessionFactory sessionFactory() {
    LocalSessionFactoryBuilder sfb = new LocalSessionFactoryBuilder(dataSource());
    sfb.addAnnotatedClasses(ContextMapping.class, DelayedInvocation.class);
    sfb.addProperties(hibernateProperties());
    return sfb.buildSessionFactory();
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:8,代码来源:ContextMappingConfiguration.java

示例10: buildSessionFactory

import org.springframework.orm.hibernate4.LocalSessionFactoryBuilder; //导入依赖的package包/类
/**
 * Registers the default Jspresso Filter.
 * <p>
 * {@inheritDoc}
 */
@Override
protected SessionFactory buildSessionFactory(LocalSessionFactoryBuilder sfb) {
  Map<String, Type> filterParameters = new HashMap<>();
  filterParameters.put(
      HibernateBackendController.JSPRESSO_SESSION_GLOBALS_LOGIN, sfb
          .getTypeResolver().heuristicType("string"));
  filterParameters.put(
      HibernateBackendController.JSPRESSO_SESSION_GLOBALS_LANGUAGE, sfb
          .getTypeResolver().heuristicType("string"));
  sfb.addFilterDefinition(new FilterDefinition(
      HibernateBackendController.JSPRESSO_SESSION_GLOBALS, null,
      filterParameters));
  return super.buildSessionFactory(sfb);
}
 
开发者ID:jspresso,项目名称:jspresso-ce,代码行数:20,代码来源:JspressoLocalSessionFactoryBean.java

示例11: buildSessionFactory

import org.springframework.orm.hibernate4.LocalSessionFactoryBuilder; //导入依赖的package包/类
@Override
protected SessionFactory buildSessionFactory(
		LocalSessionFactoryBuilder sfb) {

	getConfiguration().registerTypeOverride(
			QuantityCustomType.INSTANCE,
			new String[] { Quantity.class.getName() });
	return super.buildSessionFactory(sfb);
}
 
开发者ID:fpuna-cia,项目名称:karaku,代码行数:10,代码来源:KarakuPersistence.java

示例12: sessionFactory

import org.springframework.orm.hibernate4.LocalSessionFactoryBuilder; //导入依赖的package包/类
@Bean
public SessionFactory sessionFactory() {
    return new LocalSessionFactoryBuilder(dataSource())
            .scanPackages("net.canang.cfi.core.am")
            .scanPackages("net.canang.cfi.core.ar")
            .scanPackages("net.canang.cfi.core.bm")
            .scanPackages("net.canang.cfi.core.dd")
            .scanPackages("net.canang.cfi.core.so")
            .scanPackages("net.canang.cfi.core.gl")
            .scanPackages("net.canang.cfi.core.jm")
            .scanPackages("net.canang.cfi.core.vm")
            .addProperties(hibernateProperties())
            .buildSessionFactory();
}
 
开发者ID:rafizanbaharum,项目名称:cfi-gov,代码行数:15,代码来源:CfWebConfig.java

示例13: sessionFactory

import org.springframework.orm.hibernate4.LocalSessionFactoryBuilder; //导入依赖的package包/类
@Bean
public SessionFactory sessionFactory() {
	LocalSessionFactoryBuilder builder = new LocalSessionFactoryBuilder(
			dataSource());
	builder.scanPackages("com.hantsylabs.example.spring.model")
			.addProperties(hibernateProperties());

	return builder.buildSessionFactory();
}
 
开发者ID:hantsy,项目名称:spring4-sandbox,代码行数:10,代码来源:HibernateConfig.java

示例14: localSessionFactoryBuilder

import org.springframework.orm.hibernate4.LocalSessionFactoryBuilder; //导入依赖的package包/类
@Bean
public LocalSessionFactoryBuilder localSessionFactoryBuilder() throws PropertyVetoException {
    final LocalSessionFactoryBuilder builder = new LocalSessionFactoryBuilder(dataSource());

    builder.scanPackages("dk.freecode.**");
    builder.setNamingStrategy(namingStrategy());
    builder.setProperty("hibernate.dialect", H2Dialect.class.getName());
    builder.setProperty("hibernate.format_sql", "true");
    setPropertiesFromEnvironment(builder, "hibernate.show_sql", "hibernate.hbm2ddl.auto");

    return builder;
}
 
开发者ID:jegbjerg,项目名称:webapp-base,代码行数:13,代码来源:PersistenceConfig.java

示例15: sessionFactory

import org.springframework.orm.hibernate4.LocalSessionFactoryBuilder; //导入依赖的package包/类
@Bean
public SessionFactory sessionFactory() {
    LocalSessionFactoryBuilder builder = new LocalSessionFactoryBuilder(dataSource());
    builder.scanPackages("uk.co.yottr.model").addProperties(getHibernateProperties());
    return builder.buildSessionFactory();
}
 
开发者ID:mikehartley,项目名称:yottr,代码行数:7,代码来源:PersistenceConfig.java


注:本文中的org.springframework.orm.hibernate4.LocalSessionFactoryBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。