本文整理汇总了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;
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例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();
}
示例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();
}
示例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;
}
示例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();
}