use of org.springframework.transaction.PlatformTransactionManager in project spring-data-commons by spring-projects.
the class ChainedTransactionManagerTests method shouldThrowExceptionOnFailingRollback.
@Test(expected = UnexpectedRollbackException.class)
public void shouldThrowExceptionOnFailingRollback() throws Exception {
PlatformTransactionManager first = createFailingTransactionManager("first");
setupTransactionManagers(first);
createAndRollbackTransaction();
}
use of org.springframework.transaction.PlatformTransactionManager in project spring-session by spring-projects.
the class IndexDocTests method newJdbcOperationsSessionRepository.
@Test
@SuppressWarnings("unused")
public void newJdbcOperationsSessionRepository() {
// tag::new-jdbcoperationssessionrepository[]
JdbcTemplate jdbcTemplate = new JdbcTemplate();
// ... configure JdbcTemplate ...
PlatformTransactionManager transactionManager = new DataSourceTransactionManager();
// ... configure transactionManager ...
SessionRepository<? extends Session> repository = new JdbcOperationsSessionRepository(jdbcTemplate, transactionManager);
// end::new-jdbcoperationssessionrepository[]
}
use of org.springframework.transaction.PlatformTransactionManager in project syncope by apache.
the class DomainProcessEngineFactoryBean method getObject.
@Override
public DomainProcessEngine getObject() throws Exception {
if (engine == null) {
Map<String, ProcessEngine> engines = new HashMap<>();
ctx.getBeansOfType(DataSource.class).entrySet().stream().filter(entry -> (!entry.getKey().startsWith("local"))).forEachOrdered(entry -> {
String domain = StringUtils.substringBefore(entry.getKey(), DataSource.class.getSimpleName());
DataSource dataSource = entry.getValue();
PlatformTransactionManager transactionManager = ctx.getBean(domain + "TransactionManager", PlatformTransactionManager.class);
Object entityManagerFactory = ctx.getBean(domain + "EntityManagerFactory");
SpringProcessEngineConfiguration conf = ctx.getBean(SpringProcessEngineConfiguration.class);
conf.setDataSource(dataSource);
conf.setTransactionManager(transactionManager);
conf.setTransactionsExternallyManaged(true);
conf.setJpaEntityManagerFactory(entityManagerFactory);
if (conf.getBeans() == null) {
conf.setBeans(new SpringBeanFactoryProxyMap(ctx));
}
if (conf.getExpressionManager() == null) {
conf.setExpressionManager(new SpringExpressionManager(ctx, conf.getBeans()));
}
if (EngineServiceUtil.getIdmEngineConfiguration(conf) == null) {
conf.addEngineConfiguration(EngineConfigurationConstants.KEY_IDM_ENGINE_CONFIG, ctx.getBean(SpringIdmEngineConfiguration.class));
}
engines.put(domain, conf.buildProcessEngine());
});
engine = new DomainProcessEngine(engines);
}
return engine;
}
use of org.springframework.transaction.PlatformTransactionManager in project BroadleafCommerce by BroadleafCommerce.
the class SequenceGeneratorCorruptionDetection method onApplicationEvent.
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
if (detectSequenceGeneratorInconsistencies) {
for (Map<String, Map<String, Object>> targetModeMap : targetModeMaps) {
for (final String targetMode : targetModeMap.keySet()) {
final Map<String, Object> managerMap = targetModeMap.get(targetMode);
PlatformTransactionManager txManager = persistenceService.getTransactionManager(managerMap);
transUtil.runTransactionalOperation(new StreamCapableTransactionalOperationAdapter() {
@Override
public void execute() throws Throwable {
EntityManager em = persistenceService.getEntityManager(managerMap);
Session hibernateSession = em.unwrap(Session.class);
patchSequenceGeneratorInconsistencies(em, hibernateSession);
}
}, RuntimeException.class, txManager);
}
}
}
}
use of org.springframework.transaction.PlatformTransactionManager in project BroadleafCommerce by BroadleafCommerce.
the class PersistenceServiceImpl method populateCaches.
protected void populateCaches(String targetMode, Map<String, Object> managerMap) {
final EntityManager em = getEntityManager(managerMap);
final PlatformTransactionManager txManager = getTransactionManager(managerMap);
final EJB3ConfigurationDao ejb3ConfigurationDao = getEJB3ConfigurationDao(managerMap);
SessionFactory sessionFactory = em.unwrap(Session.class).getSessionFactory();
for (Object item : sessionFactory.getAllClassMetadata().values()) {
ClassMetadata metadata = (ClassMetadata) item;
Class<?> mappedClass = metadata.getMappedClass();
String managerCacheKey = buildManagerCacheKey(targetMode, mappedClass);
ENTITY_MANAGER_CACHE.put(managerCacheKey, em);
TRANSACTION_MANAGER_CACHE.put(managerCacheKey, txManager);
String ejb3ConfigDaoCacheKey = buildEJB3ConfigDaoCacheKey(mappedClass);
if (!EJB3_CONFIG_DAO_CACHE.containsKey(ejb3ConfigDaoCacheKey)) {
EJB3_CONFIG_DAO_CACHE.put(ejb3ConfigDaoCacheKey, ejb3ConfigurationDao);
}
}
}
Aggregations