本文整理汇总了Java中javax.persistence.spi.PersistenceProviderResolverHolder类的典型用法代码示例。如果您正苦于以下问题:Java PersistenceProviderResolverHolder类的具体用法?Java PersistenceProviderResolverHolder怎么用?Java PersistenceProviderResolverHolder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PersistenceProviderResolverHolder类属于javax.persistence.spi包,在下文中一共展示了PersistenceProviderResolverHolder类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fixDeprecatedHibernateWarning
import javax.persistence.spi.PersistenceProviderResolverHolder; //导入依赖的package包/类
/**
* fixes the warning (Encountered a deprecated javax.persistence.spi.PersistenceProvider [org.hibernate.ejb
* .HibernatePersistence]; use [org.hibernate.jpa.HibernatePersistenceProvider] instead.)
*
* must be called before getting the EntityManagerFactory
*/
private static void fixDeprecatedHibernateWarning() {
PersistenceProviderResolverHolder.setPersistenceProviderResolver(new PersistenceProviderResolver() {
private final List<PersistenceProvider> providers_ =
Arrays.asList(new PersistenceProvider[]{new HibernatePersistenceProvider()});
@Override
public List<PersistenceProvider> getPersistenceProviders() {
return providers_;
}
@Override
public void clearCachedProviders() {
}
});
}
示例2: guessDelegate
import javax.persistence.spi.PersistenceProviderResolverHolder; //导入依赖的package包/类
private void guessDelegate() {
// https://issues.apache.org/jira/browse/SIRONA-44
// https://github.com/javamelody/javamelody/issues/460
final List<PersistenceProvider> persistenceProviders = PersistenceProviderResolverHolder
.getPersistenceProviderResolver().getPersistenceProviders();
for (final PersistenceProvider persistenceProvider : persistenceProviders) {
if (!getClass().isInstance(persistenceProvider)) {
delegate = persistenceProvider;
break;
}
}
if (delegate == null) {
for (final String provider : PROVIDERS) {
try {
delegate = newPersistence(provider);
break;
} catch (final Throwable th2) { // NOPMD
continue;
}
}
if (delegate == null) {
throw new IllegalStateException(
new ClassNotFoundException("Can't find a delegate"));
}
}
}
示例3: deploy
import javax.persistence.spi.PersistenceProviderResolverHolder; //导入依赖的package包/类
@Deployment
public static WebArchive deploy()
{
// set the dummy PersistenceProviderResolver which creates our DummyEntityManagerFactory
PersistenceProviderResolverHolder.setPersistenceProviderResolver(new TestPersistenceProviderResolver());
JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "unitDefinitionTest.jar")
.addPackage(ArchiveUtils.SHARED_PACKAGE)
.addClass(PersistenceConfigurationProviderTest.class)
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
return ShrinkWrap.create(WebArchive.class)
.addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndJpaArchive())
.addAsLibraries(testJar)
.addAsWebInfResource(ArchiveUtils.getBeansXml(), "beans.xml");
}
示例4: deploy
import javax.persistence.spi.PersistenceProviderResolverHolder; //导入依赖的package包/类
@Deployment
public static WebArchive deploy()
{
// set the dummy PersistenceProviderResolver which creates our DummyEntityManagerFactory
PersistenceProviderResolverHolder.setPersistenceProviderResolver(new TestPersistenceProviderResolver());
JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "unitDefinitionTest.jar")
.addPackage(ArchiveUtils.SHARED_PACKAGE)
.addPackage(EntityManagerFactoryProducerTest.class.getPackage().getName())
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
.addAsResource(new StringAsset(TestPersistenceProviderResolver.class.getName()),
"META-INF/services/javax.persistence.spi.PersistenceProviderResolver");
return ShrinkWrap.create(WebArchive.class)
.addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndJpaArchive())
.addAsLibraries(testJar)
.addAsWebInfResource(ArchiveUtils.getBeansXml(), "beans.xml");
}
示例5: start
import javax.persistence.spi.PersistenceProviderResolverHolder; //导入依赖的package包/类
@Override
public void start(BundleContext context) throws Exception {
emfResolver = new EMFBuilderServiceResolver(context);
tracker = new ServiceTracker<PersistenceProvider, PersistenceProvider>(context,
PersistenceProvider.class, null);
tracker.open();
PersistenceProviderResolverHolder.setPersistenceProviderResolver(this);
}
示例6: getJpaPersistence
import javax.persistence.spi.PersistenceProviderResolverHolder; //导入依赖的package包/类
private PersistenceProvider getJpaPersistence() {
final List<PersistenceProvider> persistenceProviders = PersistenceProviderResolverHolder
.getPersistenceProviderResolver().getPersistenceProviders();
for (final PersistenceProvider persistenceProvider : persistenceProviders) {
if (persistenceProvider instanceof JpaPersistence) {
return persistenceProvider;
}
}
throw new IllegalStateException("JpaPersistence not found in PersistenceProviders");
}
示例7: JPA
import javax.persistence.spi.PersistenceProviderResolverHolder; //导入依赖的package包/类
private JPA() {
List<PersistenceProvider> providers = PersistenceProviderResolverHolder.getPersistenceProviderResolver().getPersistenceProviders();
if (providers != null) {
String providerClass = providers.get(0).getClass().getCanonicalName();
if (providerClass.equals(HIBERNATE_PERSISTENCE) || providerClass.equals(HIBERNATE_JPA_PERSISTENCE)) {
cacheableHint = "org.hibernate.cacheable";
} else if (providerClass.equals(ECLIPSE_PERSISTENCE)) {
cacheableHint = "eclipselink.query-results-cache";
} else if (providerClass.equals(OPENJPA_PERSISTENCE)) {
cacheableHint = "openjpa.QueryCache";
}
}
}
示例8: stop
import javax.persistence.spi.PersistenceProviderResolverHolder; //导入依赖的package包/类
@Override
public void stop(BundleContext context) throws Exception {
PersistenceProviderResolverHolder.setPersistenceProviderResolver(null);
tracker.close();
emfResolver.close();
}
示例9: getProviders
import javax.persistence.spi.PersistenceProviderResolverHolder; //导入依赖的package包/类
protected static List<PersistenceProvider> getProviders() {
return PersistenceProviderResolverHolder
.getPersistenceProviderResolver()
.getPersistenceProviders();
}
示例10: getPersistenceProvider
import javax.persistence.spi.PersistenceProviderResolverHolder; //导入依赖的package包/类
@Produces
@ApplicationScoped
public PersistenceProvider getPersistenceProvider() {
return PersistenceProviderResolverHolder.getPersistenceProviderResolver().getPersistenceProviders().get(0);
}
示例11: getProviders
import javax.persistence.spi.PersistenceProviderResolverHolder; //导入依赖的package包/类
protected List<PersistenceProvider> getProviders() {
return PersistenceProviderResolverHolder.getPersistenceProviderResolver().getPersistenceProviders();
}
示例12: setupClass
import javax.persistence.spi.PersistenceProviderResolverHolder; //导入依赖的package包/类
@BeforeClass
public static void setupClass() {
System.setProperty(ECLIPSELINK_PERSISTENCEXML, "META-INF/eclipselink-plainjpa-persistence.xml");
PersistenceProviderResolverHolder.setPersistenceProviderResolver(new EclipseLinkOnlyPersistenceProviderResolve());
emf = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
}