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