本文整理汇总了Java中javax.persistence.SynchronizationType类的典型用法代码示例。如果您正苦于以下问题:Java SynchronizationType类的具体用法?Java SynchronizationType怎么用?Java SynchronizationType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SynchronizationType类属于javax.persistence包,在下文中一共展示了SynchronizationType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JtaEntityManager
import javax.persistence.SynchronizationType; //导入依赖的package包/类
public JtaEntityManager(final String unitName, final JtaEntityManagerRegistry registry, final EntityManagerFactory entityManagerFactory,
final Map properties, final boolean extended, final String synchronizationType) {
if (registry == null) {
throw new NullPointerException("registry is null");
}
if (entityManagerFactory == null) {
throw new NullPointerException("entityManagerFactory is null");
}
this.unitName = unitName;
this.registry = registry;
this.entityManagerFactory = entityManagerFactory;
this.properties = properties;
this.extended = extended;
this.synchronizationType = !isJPA21(entityManagerFactory) || synchronizationType == null ?
null : SynchronizationType.valueOf(synchronizationType.toUpperCase(Locale.ENGLISH));
final String globalTimerConfig = SystemInstance.get().getProperty("openejb.jpa.timer");
final Object localTimerConfig = properties == null ? null : properties.get("openejb.jpa.timer");
this.timer = localTimerConfig == null ? (globalTimerConfig == null || Boolean.parseBoolean(globalTimerConfig)) : Boolean.parseBoolean(localTimerConfig.toString());
logger = unitName == null ? baseLogger : baseLogger.getChildLogger(unitName);
final String wrapConfig = ReloadableEntityManagerFactory.class.isInstance(entityManagerFactory) ?
ReloadableEntityManagerFactory.class.cast(entityManagerFactory).getUnitProperties().getProperty("openejb.jpa.query.wrap-no-tx", "true") : "true";
this.wrapNoTxQueries = wrapConfig == null || "true".equalsIgnoreCase(wrapConfig);
}
示例2: DatabaseReadOnlyNetwork
import javax.persistence.SynchronizationType; //导入依赖的package包/类
public DatabaseReadOnlyNetwork(EntityManager entityManager, boolean isShortTerm) {
super(new EntityManagerImpl(entityManager.unwrap(ServerSession.class), SynchronizationType.UNSYNCHRONIZED), isShortTerm);
ServerSession server = entityManager.unwrap(ServerSession.class);
if (!server.getProperties().containsKey("network")) {
server.setProperty("network", this);
}
}
示例3: isJPA21
import javax.persistence.SynchronizationType; //导入依赖的package包/类
public static boolean isJPA21(final EntityManagerFactory entityManagerFactory) {
return ReloadableEntityManagerFactory.class.isInstance(entityManagerFactory) ?
hasMethod(
ReloadableEntityManagerFactory.class.cast(entityManagerFactory).getEntityManagerFactoryCallable().getProvider(),
"generateSchema", String.class, Map.class)
: hasMethod(entityManagerFactory.getClass(), "createEntityManager", SynchronizationType.class);
}
示例4: createEntityManager
import javax.persistence.SynchronizationType; //导入依赖的package包/类
@Override
public EntityManager createEntityManager(final SynchronizationType synchronizationType) {
EntityManager em;
try {
em = delegate().createEntityManager(synchronizationType);
} catch (final LinkageError le) {
em = delegate.createEntityManager(synchronizationType);
}
if (logCriteriaJpql) {
return new QueryLogEntityManager(em, logCriteriaJpqlLevel);
}
return em;
}
示例5: createEntityManagers
import javax.persistence.SynchronizationType; //导入依赖的package包/类
private Index<EntityManagerFactory, JtaEntityManagerRegistry.EntityManagerTracker> createEntityManagers(final BeanContext beanContext) {
// create the extended entity managers
final Index<EntityManagerFactory, BeanContext.EntityManagerConfiguration> factories = beanContext.getExtendedEntityManagerFactories();
Index<EntityManagerFactory, JtaEntityManagerRegistry.EntityManagerTracker> entityManagers = null;
if (factories != null && factories.size() > 0) {
entityManagers = new Index<>(new ArrayList<>(factories.keySet()));
for (final Map.Entry<EntityManagerFactory, BeanContext.EntityManagerConfiguration> entry : factories.entrySet()) {
final EntityManagerFactory entityManagerFactory = entry.getKey();
JtaEntityManagerRegistry.EntityManagerTracker entityManagerTracker = entityManagerRegistry.getInheritedEntityManager(entityManagerFactory);
final EntityManager entityManager;
if (entityManagerTracker == null) {
final Map properties = entry.getValue().getProperties();
final SynchronizationType synchronizationType = entry.getValue().getSynchronizationType();
if (synchronizationType != null) {
if (properties != null) {
entityManager = entityManagerFactory.createEntityManager(synchronizationType, properties);
} else {
entityManager = entityManagerFactory.createEntityManager(synchronizationType);
}
} else if (properties != null) {
entityManager = entityManagerFactory.createEntityManager(properties);
} else {
entityManager = entityManagerFactory.createEntityManager();
}
entityManagerTracker = new JtaEntityManagerRegistry.EntityManagerTracker(entityManager, synchronizationType != SynchronizationType.UNSYNCHRONIZED);
} else {
entityManagerTracker.incCounter();
}
entityManagers.put(entityManagerFactory, entityManagerTracker);
}
}
return entityManagers;
}
示例6: createEntityManagers
import javax.persistence.SynchronizationType; //导入依赖的package包/类
private Index<EntityManagerFactory, JtaEntityManagerRegistry.EntityManagerTracker> createEntityManagers(final BeanContext beanContext) {
// create the extended entity managers
final Index<EntityManagerFactory, BeanContext.EntityManagerConfiguration> factories = beanContext.getExtendedEntityManagerFactories();
Index<EntityManagerFactory, JtaEntityManagerRegistry.EntityManagerTracker> entityManagers = null;
if (factories != null && factories.size() > 0) {
entityManagers = new Index<EntityManagerFactory, JtaEntityManagerRegistry.EntityManagerTracker>(new ArrayList<EntityManagerFactory>(factories.keySet()));
for (final Map.Entry<EntityManagerFactory, BeanContext.EntityManagerConfiguration> entry : factories.entrySet()) {
final EntityManagerFactory entityManagerFactory = entry.getKey();
JtaEntityManagerRegistry.EntityManagerTracker entityManagerTracker = entityManagerRegistry.getInheritedEntityManager(entityManagerFactory);
final EntityManager entityManager;
if (entityManagerTracker == null) {
final SynchronizationType synchronizationType = entry.getValue().getSynchronizationType();
final Map properties = entry.getValue().getProperties();
if (synchronizationType != null) {
if (properties != null) {
entityManager = entityManagerFactory.createEntityManager(synchronizationType, properties);
} else {
entityManager = entityManagerFactory.createEntityManager(synchronizationType);
}
} else if (properties != null) {
entityManager = entityManagerFactory.createEntityManager(properties);
} else {
entityManager = entityManagerFactory.createEntityManager();
}
entityManagerTracker = new JtaEntityManagerRegistry.EntityManagerTracker(entityManager, synchronizationType != SynchronizationType.UNSYNCHRONIZED);
} else {
entityManagerTracker.incCounter();
}
entityManagers.put(entityManagerFactory, entityManagerTracker);
}
}
return entityManagers;
}
示例7: persistenceContext
import javax.persistence.SynchronizationType; //导入依赖的package包/类
private InjectionPoint persistenceContext(String unitName) {
final InjectionPoint ip = mock(InjectionPoint.class);
final Annotated annotated = mock(Annotated.class);
when(ip.getAnnotated()).thenReturn(annotated);
final PersistenceContext annotation = new PersistenceContext() {
@Override
public Class<? extends Annotation> annotationType() {
return null;
}
@Override
public String name() {
return null;
}
@Override
public String unitName() {
return unitName;
}
@Override
public PersistenceContextType type() {
return null;
}
@Override
public SynchronizationType synchronization() {
return null;
}
@Override
public PersistenceProperty[] properties() {
return new PersistenceProperty[0];
}
};
when(annotated.getAnnotation(PersistenceContext.class)).thenReturn(annotation);
return ip;
}
示例8: createEntityManager
import javax.persistence.SynchronizationType; //导入依赖的package包/类
@Override
public EntityManager createEntityManager(SynchronizationType arg0) {
EntityManager em = nativeEntityManagerFactory.createEntityManager(arg0);
log.debug("create new CibetEntityManager with native " + em);
return new CibetEntityManager(this, em, loadEager);
}
示例9: createEntityManager
import javax.persistence.SynchronizationType; //导入依赖的package包/类
@Override
public EntityManager createEntityManager(SynchronizationType synchronizationType) {
return null;
}
示例10: createEntityManager
import javax.persistence.SynchronizationType; //导入依赖的package包/类
public EntityManager createEntityManager(SynchronizationType type, Map properties) {
return delegate.createEntityManager(type, properties);
}
示例11: createEntityManager
import javax.persistence.SynchronizationType; //导入依赖的package包/类
public SecureEntityManager createEntityManager(SynchronizationType synchronizationType, Map properties) {
return createSecureEntityManager(super.createEntityManager(synchronizationType, properties), properties);
}
示例12: createEntityManager
import javax.persistence.SynchronizationType; //导入依赖的package包/类
@Override
public EntityManager createEntityManager(SynchronizationType arg0) {
return null;
}
示例13: createEntityManager
import javax.persistence.SynchronizationType; //导入依赖的package包/类
public EntityManager createEntityManager(SynchronizationType st) {
throw new UnsupportedOperationException("Not supported.");
}
示例14: PersistenceContextResourceFactory
import javax.persistence.SynchronizationType; //导入依赖的package包/类
public PersistenceContextResourceFactory(String unitName, EntityManagerFactory emf, TransactionType transactionType, SynchronizationType sync) {
this.unitName = unitName;
this.emf = emf;
this.sync = sync;
this.transactionType = transactionType;
}
示例15: getEntityManager
import javax.persistence.SynchronizationType; //导入依赖的package包/类
public static EntityManager getEntityManager(SynchronizationType st) {
return emf.createEntityManager(st);
}