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


Java HibernatePersistence类代码示例

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


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

示例1: start

import org.hibernate.ejb.HibernatePersistence; //导入依赖的package包/类
@Override
public void start(BundleContext context) throws Exception {
    this.bundleContext = bundleContext;
    debugPrintln("Activating ...");

    HibernatePersistence persistenceProvider = new HibernatePersistence();

    Dictionary<String, String> props = new Hashtable<String, String>();
    props.put(JAVAX_PERSISTENCE_PROVIDER_PROP, persistenceProvider
            .getClass().getName());

    serviceRegistration = context
            .registerService(PersistenceProvider.class.getName(),
                    persistenceProvider, props);

    debugPrintln("Service: ".concat(PersistenceProvider.class.getName())
            .concat(" registered. Bundle activated."));
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:19,代码来源:Activator.java

示例2: entityManagerFactory

import org.hibernate.ejb.HibernatePersistence; //导入依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LOGGER.info("Configurando [entityManagerFactory]...");
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();

    entityManagerFactoryBean.setDataSource(dataSource());
    entityManagerFactoryBean.setPackagesToScan("br.com.pandox.nursery");
    entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistence.class);

    Properties hibernateProperties = new Properties();

    hibernateProperties.put("hibernate.hbm2ddl.auto", "create");

    hibernateProperties.put("hibernate.dialect", env.getProperty("hibernate.dialect"));
    hibernateProperties.put("hibernate.format_sql", "true");
    hibernateProperties.put("hibernate.show_sql", "false");

    entityManagerFactoryBean.setJpaProperties(hibernateProperties);

    LOGGER.info(entityManagerFactoryBean);
    return entityManagerFactoryBean;
}
 
开发者ID:matheusmessora,项目名称:nursery,代码行数:23,代码来源:ApplicationBoot.java

示例3: springfieldEntityManagerFactory

import org.hibernate.ejb.HibernatePersistence; //导入依赖的package包/类
public LocalContainerEntityManagerFactoryBean springfieldEntityManagerFactory() throws Exception{
	logger.trace("create LocalContainerEntityManagerFactoryBean "+basePackage);
	String dialect = HibernateDialectType.fromMetaData(dataSource).getDialect(); 
	
	Properties p = new Properties();
	p.put("hibernate.cache.provider_class",  "org.hibernate.cache.HashtableCacheProvider");
	p.put("hibernate.dialect" , dialect);
	p.put("hibernate.show_sql", "true");
	p.put("hibernate.format_sql", "true");
	p.put("hibernate.hbm2ddl.auto", "update");
	
	LocalContainerEntityManagerFactoryBean b = new LocalContainerEntityManagerFactoryBean();
	b.setPersistenceUnitName("springfield");
	b.setPersistenceProviderClass(HibernatePersistence.class);
	b.setJpaProperties(p);

	b.setDataSource(dataSource);
	b.setPackagesToScan(basePackage);
	//b.afterPropertiesSet();
	
	return b;
}
 
开发者ID:u2ware,项目名称:springfield,代码行数:23,代码来源:ContextRepositoryJpa.java

示例4: createEntityManagerFactory

import org.hibernate.ejb.HibernatePersistence; //导入依赖的package包/类
public static EntityManagerFactory createEntityManagerFactory(String persistenceUnitName, Map properties) {
    
	EntityManagerFactory emf = null;
    List<PersistenceProvider> providers = getProviders();
    PersistenceProvider defaultProvider = null;
    for (PersistenceProvider provider : providers) {
        if (provider instanceof HibernatePersistence) {
            defaultProvider = provider;
            continue;
        }
        emf = provider.createEntityManagerFactory(persistenceUnitName, properties);
        if (emf != null) {
            break;
        }
    }
    if (emf == null && defaultProvider != null)
        emf = defaultProvider.createEntityManagerFactory( persistenceUnitName, properties );
    if ( emf == null ) {
        throw new PersistenceException( "No Persistence provider for EntityManager named " + persistenceUnitName );
    }
    return emf;
}
 
开发者ID:intercommit,项目名称:hibhik,代码行数:23,代码来源:CustomPersistence.java

示例5: entityManagerFactoryBean

import org.hibernate.ejb.HibernatePersistence; //导入依赖的package包/类
/**
 * Entity manager factory bean.
 * 
 * @return the local container entity manager factory bean
 */
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
        LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
        factoryBean.setDataSource(this.dataSource());
        factoryBean
                        .setPackagesToScan(environment.getRequiredProperty(PACKAGES_TO_SCAN));
        factoryBean.setPersistenceProviderClass(HibernatePersistence.class);

        Properties jpaProperties = new Properties();
        jpaProperties.put(HIBERNATE_DIALECT,
                        environment.getRequiredProperty(HIBERNATE_DIALECT));
        jpaProperties.put(HIBERNATE_FORMAT_SQL, environment.getRequiredProperty(HIBERNATE_FORMAT_SQL));
        jpaProperties.put(HIBERNATE_SHOW_SQL, environment.getRequiredProperty(HIBERNATE_SHOW_SQL));
        
        factoryBean.setJpaProperties(jpaProperties);
        return factoryBean;
}
 
开发者ID:npaulus,项目名称:Daily-Email-WebApp,代码行数:23,代码来源:PersistenceJpaConfig.java

示例6: entityManagerFactory

import org.hibernate.ejb.HibernatePersistence; //导入依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
	LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
	entityManagerFactoryBean.setDataSource(dataSource());
	entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistence.class);
	entityManagerFactoryBean.setPackagesToScan(env.getRequiredProperty(PROP_ENTITYMANAGER_PACKAGES_TO_SCAN));

	entityManagerFactoryBean.setJpaProperties(getHibernateProperties());

	return entityManagerFactoryBean;
}
 
开发者ID:noveogroup-amorgunov,项目名称:spring-mvc-react,代码行数:12,代码来源:SpringWebConfig.java

示例7: newEntityManagerFactory

import org.hibernate.ejb.HibernatePersistence; //导入依赖的package包/类
protected EntityManagerFactory newEntityManagerFactory() {
    PersistenceUnitInfo persistenceUnitInfo = persistenceUnitInfo(getClass().getSimpleName());
    Map<String, Object> configuration = new HashMap<String, Object>();

    HibernatePersistence hibernatePersistence = new HibernatePersistence();
    return hibernatePersistence.createContainerEntityManagerFactory(persistenceUnitInfo, configuration);
}
 
开发者ID:vladmihalcea,项目名称:hibernate-types,代码行数:8,代码来源:AbstractTest.java

示例8: createParser

import org.hibernate.ejb.HibernatePersistence; //导入依赖的package包/类
@Before
public void createParser() throws IOException {
    entityManagerFactory = new HibernatePersistence().createEntityManagerFactory("metamodel", null);
    Set<String> ormXmlLocations = new HashSet<String>();
    ormXmlLocations.add("META-INF/all.orm.xml");
    ormXmlLocations.add("META-INF/empty.orm.xml");
    ormXmlLocations.add("META-INF/parent.orm.xml");
    parser = new NamedQueryParser(entityManagerFactory.getMetamodel(), ormXmlLocations);
}
 
开发者ID:ArneLimburg,项目名称:jpasecurity,代码行数:10,代码来源:NamedQueryParserTest.java

示例9: createEntityManagerFactoryBean

import org.hibernate.ejb.HibernatePersistence; //导入依赖的package包/类
protected LocalContainerEntityManagerFactoryBean createEntityManagerFactoryBean(DataSource dataSource, String dialectClassName) {
    Map<String, String> properties = new HashMap<String, String>();
    properties.put(org.hibernate.cfg.Environment.HBM2DDL_AUTO, "update");
    properties.put(org.hibernate.cfg.Environment.DIALECT, dialectClassName);
    properties.put(org.hibernate.cfg.Environment.SHOW_SQL, "true");

    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource);
    em.setPackagesToScan(Album.class.getPackage().getName());
    em.setPersistenceProvider(new HibernatePersistence());
    em.setJpaPropertyMap(properties);
    return em;
}
 
开发者ID:pivotalservices,项目名称:concourse-spring-music,代码行数:14,代码来源:AbstractJpaRepositoryConfig.java

示例10: entityManagerFactory

import org.hibernate.ejb.HibernatePersistence; //导入依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws ClassNotFoundException {
    LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean();

    System.out.println("url: " + environment.getProperty(PROPERTY_NAME_DATABASE_URL));

    bean.setDataSource(dataSource());
    bean.setPackagesToScan(environment.getRequiredProperty(PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN));
    bean.setPersistenceProviderClass(HibernatePersistence.class);
    // bean.setPersistenceUnitName(environment
    // .getRequiredProperty(PROPERTY_NAME_PERSISTENCE_UNIT_NAME));

    HibernateJpaVendorAdapter va = new HibernateJpaVendorAdapter();
    bean.setJpaVendorAdapter(va);

    Properties jpaProperties = new Properties();
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_DIALECT,
            environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_DIALECT));
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_FORMAT_SQL,
            environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_FORMAT_SQL));
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY,
            environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY));
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_SHOW_SQL,
            environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_SHOW_SQL));
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_HBM2DDL_AUTO,
            environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_HBM2DDL_AUTO));

    bean.setJpaProperties(jpaProperties);

    return bean;
}
 
开发者ID:beargiles,项目名称:spring-entity-listener,代码行数:32,代码来源:ApplicationContext.java

示例11: entityManagerFactory

import org.hibernate.ejb.HibernatePersistence; //导入依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws ClassNotFoundException {
    LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean();

    bean.setDataSource(dataSource());
    bean.setPackagesToScan(environment.getRequiredProperty(PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN));
    bean.setPersistenceProviderClass(HibernatePersistence.class);
    // bean.setPersistenceUnitName(environment
    // .getRequiredProperty(PROPERTY_NAME_PERSISTENCE_UNIT_NAME));

    HibernateJpaVendorAdapter va = new HibernateJpaVendorAdapter();
    bean.setJpaVendorAdapter(va);

    Properties jpaProperties = new Properties();
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_DIALECT, "org.hibernate.dialect.H2Dialect");
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_FORMAT_SQL,
            environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_FORMAT_SQL));
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY,
            environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY));
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_SHOW_SQL,
            environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_SHOW_SQL));
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_HBM2DDL_AUTO,
            environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_HBM2DDL_AUTO));

    bean.setJpaProperties(jpaProperties);

    return bean;
}
 
开发者ID:beargiles,项目名称:project-student,代码行数:29,代码来源:TestPersistenceJpaConfig.java

示例12: emf

import org.hibernate.ejb.HibernatePersistence; //导入依赖的package包/类
@Bean(name="entityManagerFactory")
@DependsOn({"liquibase", "dataSource"})
FactoryBean<EntityManagerFactory> emf(JpaVendorAdapter jpaVendorAdapter) {
    SimpleHiloIdentifierGenerator.setDataSource(dataSource());
    LocalContainerEntityManagerFactoryBean fb = new LocalContainerEntityManagerFactoryBean();
    fb.setJpaProperties(hibernateProperties());
    fb.setDataSource(dataSource());
    fb.setPersistenceProviderClass(HibernatePersistence.class);
    fb.setPackagesToScan("io.cloudslang");
    fb.setJpaVendorAdapter(jpaVendorAdapter);
    return fb;
}
 
开发者ID:CloudSlang,项目名称:score,代码行数:13,代码来源:ExecutionStateRepositoryTest.java

示例13: entityManagerFactory

import org.hibernate.ejb.HibernatePersistence; //导入依赖的package包/类
@Bean
@DependsOn("liquibase")
FactoryBean<EntityManagerFactory> entityManagerFactory(JpaVendorAdapter jpaVendorAdapter) {
	LocalContainerEntityManagerFactoryBean fb = new LocalContainerEntityManagerFactoryBean();
	fb.setDataSource(dataSource());
	fb.setPersistenceProviderClass(HibernatePersistence.class);
	fb.setPackagesToScan("io.cloudslang.engine.partitions");
	fb.setJpaVendorAdapter(jpaVendorAdapter);
	return fb;
}
 
开发者ID:CloudSlang,项目名称:score,代码行数:11,代码来源:PartitionTemplateWithEmfTest.java

示例14: emf

import org.hibernate.ejb.HibernatePersistence; //导入依赖的package包/类
@Bean(name="entityManagerFactory")
@DependsOn("liquibase")
FactoryBean<EntityManagerFactory> emf(JpaVendorAdapter jpaVendorAdapter) {
	LocalContainerEntityManagerFactoryBean fb = new LocalContainerEntityManagerFactoryBean();
	fb.setJpaProperties(hibernateProperties());
	fb.setDataSource(dataSource());
	fb.setPersistenceProviderClass(HibernatePersistence.class);
	fb.setPackagesToScan("io.cloudslang.engine.versioning");
	fb.setJpaVendorAdapter(jpaVendorAdapter);
	return fb;
}
 
开发者ID:CloudSlang,项目名称:score,代码行数:12,代码来源:VersionRepositoryTest.java

示例15: emf

import org.hibernate.ejb.HibernatePersistence; //导入依赖的package包/类
@Bean(name="entityManagerFactory")
@DependsOn("liquibase")
FactoryBean<EntityManagerFactory> emf(JpaVendorAdapter jpaVendorAdapter) {
	LocalContainerEntityManagerFactoryBean fb = new LocalContainerEntityManagerFactoryBean();
	fb.setJpaProperties(hibernateProperties());
	fb.setDataSource(dataSource());
	fb.setPersistenceProviderClass(HibernatePersistence.class);
	fb.setPackagesToScan("io.cloudslang.engine.node");
	fb.setJpaVendorAdapter(jpaVendorAdapter);
	return fb;
}
 
开发者ID:CloudSlang,项目名称:score,代码行数:12,代码来源:WorkerNodeServiceTest.java


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