Java Code Examples for org.springframework.transaction.annotation.Propagation#REQUIRES_NEW
The following examples show how to use
org.springframework.transaction.annotation.Propagation#REQUIRES_NEW .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseDao.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
/** * * @param obj * @return the generated identifier. * @throws AccessException */ @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, isolation = Isolation.REPEATABLE_READ) public Serializable save(final O obj) throws AccessException { Validate.notNull(obj); if (avoidNullIdCheckBeforeSave == false) { Validate.isTrue(obj.getId() == null); } checkLoggedInUserInsertAccess(obj); accessChecker.checkRestrictedOrDemoUser(); return internalSave(obj); }
Example 2
Source File: BusinessObjectDataAttributeServiceImpl.java From herd with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} * <p/> * This implementation starts a new transaction. */ @NamespacePermission(fields = "#businessObjectDataKey?.namespace", permissions = NamespacePermissionEnum.READ) @Override @Transactional(propagation = Propagation.REQUIRES_NEW) public BusinessObjectDataAttributeKeys getBusinessObjectDataAttributes(BusinessObjectDataKey businessObjectDataKey) { return getBusinessObjectDataAttributesImpl(businessObjectDataKey); }
Example 3
Source File: DbmSendMessageRepository.java From onetwo with Apache License 2.0 | 5 votes |
@Override @Transactional(propagation=Propagation.REQUIRES_NEW) public void batchUpdateToSent(Collection<SendMessageContext<?>> ctxs) { List<SendMessageEntity> messages = ctxs.stream().map(ctx -> { SendMessageEntity e = ctx.getMessageEntity(); e.setState(SendStates.SENT); return e; }).collect(Collectors.toList()); getBaseEntityManager().getSessionFactory().getSession().batchUpdate(messages); }
Example 4
Source File: UserDao.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
/** * Ohne Zugangsbegrenzung. Wird bei Anmeldung benötigt. * @param username * @param encryptedPassword * @return */ @SuppressWarnings("unchecked") @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW) public PFUserDO authenticateUser(final String username, final String password) { Validate.notNull(username); Validate.notNull(password); PFUserDO user = getUser(username, password, true); if (user != null) { final int loginFailures = user.getLoginFailures(); final Timestamp lastLogin = user.getLastLogin(); user.setLastLogin(new Timestamp(new Date().getTime())); user.setLoginFailures(0); user.setMinorChange(true); // Avoid re-indexing of all dependent objects. internalUpdate(user, false); if (user.hasSystemAccess() == false) { log.warn("Deleted/deactivated user tried to login: " + user); return null; } final PFUserDO contextUser = new PFUserDO(); contextUser.copyValuesFrom(user); contextUser.setLoginFailures(loginFailures); // Restore loginFailures for current user session. contextUser.setLastLogin(lastLogin); // Restore lastLogin for current user session. contextUser.setPassword(null); return contextUser; } final List<PFUserDO> list = getHibernateTemplate().find("from PFUserDO u where u.username = ?", username); if (list != null && list.isEmpty() == false && list.get(0) != null) { user = list.get(0); user.setLoginFailures(user.getLoginFailures() + 1); internalUpdate(user); } return null; }
Example 5
Source File: CustomAuditEventRepository.java From ehcache3-samples with Apache License 2.0 | 5 votes |
@Override @Transactional(propagation = Propagation.REQUIRES_NEW) public void add(AuditEvent event) { if (!AUTHORIZATION_FAILURE.equals(event.getType()) && !Constants.ANONYMOUS_USER.equals(event.getPrincipal())) { PersistentAuditEvent persistentAuditEvent = new PersistentAuditEvent(); persistentAuditEvent.setPrincipal(event.getPrincipal()); persistentAuditEvent.setAuditEventType(event.getType()); persistentAuditEvent.setAuditEventDate(event.getTimestamp()); Map<String, String> eventData = auditEventConverter.convertDataToStrings(event.getData()); persistentAuditEvent.setData(truncate(eventData)); persistenceAuditEventRepository.save(persistentAuditEvent); } }
Example 6
Source File: JPAUserDAO.java From syncope with Apache License 2.0 | 5 votes |
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true) @Override public Collection<ExternalResource> findAllResources(final User user) { Set<ExternalResource> result = new HashSet<>(); result.addAll(user.getResources()); findAllGroups(user).forEach(group -> result.addAll(group.getResources())); return result; }
Example 7
Source File: NotificationEventDao.java From olat with Apache License 2.0 | 5 votes |
@Retryable @Transactional(propagation = Propagation.REQUIRES_NEW) public void updateEvents(List<NotificationEvent> events, NotificationEvent.Status status) { for (NotificationEvent event : events) { event = genericDao.findById(event.getId()); event.setStatus(status); event.getSubscription().setLastNotifiedDate(new Date()); updateEvent(event); } }
Example 8
Source File: BusinessObjectDataStorageUnitStatusServiceImpl.java From herd with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} * <p/> * This implementation starts a new transaction. */ @PublishNotificationMessages @NamespacePermission(fields = "#businessObjectDataStorageUnitKey.namespace", permissions = NamespacePermissionEnum.WRITE) @Override @Transactional(propagation = Propagation.REQUIRES_NEW) public BusinessObjectDataStorageUnitStatusUpdateResponse updateBusinessObjectDataStorageUnitStatus( BusinessObjectDataStorageUnitKey businessObjectDataStorageUnitKey, BusinessObjectDataStorageUnitStatusUpdateRequest request) { return updateBusinessObjectDataStorageUnitStatusImpl(businessObjectDataStorageUnitKey, request); }
Example 9
Source File: CustomAuditEventRepository.java From TeamDojo with Apache License 2.0 | 5 votes |
@Override @Transactional(propagation = Propagation.REQUIRES_NEW) public void add(AuditEvent event) { if (!AUTHORIZATION_FAILURE.equals(event.getType()) && !Constants.ANONYMOUS_USER.equals(event.getPrincipal())) { PersistentAuditEvent persistentAuditEvent = new PersistentAuditEvent(); persistentAuditEvent.setPrincipal(event.getPrincipal()); persistentAuditEvent.setAuditEventType(event.getType()); persistentAuditEvent.setAuditEventDate(event.getTimestamp()); Map<String, String> eventData = auditEventConverter.convertDataToStrings(event.getData()); persistentAuditEvent.setData(truncate(eventData)); persistenceAuditEventRepository.save(persistentAuditEvent); } }
Example 10
Source File: BusinessObjectDataServiceImpl.java From herd with Apache License 2.0 | 5 votes |
@NamespacePermission(fields = "#request.namespace", permissions = NamespacePermissionEnum.READ) @Override @Transactional(propagation = Propagation.REQUIRES_NEW) public BusinessObjectDataDdl generateBusinessObjectDataDdl(BusinessObjectDataDdlRequest request) { return generateBusinessObjectDataDdlImpl(request, false); }
Example 11
Source File: EmrServiceImpl.java From herd with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} * <p/> * This implementation starts a new transaction. */ @NamespacePermission(fields = "#request?.namespace", permissions = NamespacePermissionEnum.WRITE) @Override @Transactional(propagation = Propagation.REQUIRES_NEW) public EmrMasterSecurityGroup addSecurityGroupsToClusterMaster(EmrMasterSecurityGroupAddRequest request) throws Exception { return addSecurityGroupsToClusterMasterImpl(request); }
Example 12
Source File: SimpleQueryImpl.java From zstack with Apache License 2.0 | 4 votes |
@Override @Transactional(readOnly=true, propagation=Propagation.REQUIRES_NEW) public T find() { return _find(); }
Example 13
Source File: TransactionalBean2.java From redisson with Apache License 2.0 | 4 votes |
@Transactional(propagation = Propagation.REQUIRES_NEW) public void testInNewTransaction() { RTransaction transaction = transactionManager.getCurrentTransaction(); transaction.getMap("tr2").put("2", "4"); }
Example 14
Source File: SimpleQueryImpl.java From zstack with Apache License 2.0 | 4 votes |
@Override @Transactional(readOnly=true, propagation=Propagation.REQUIRES_NEW) public <K> List<K> listValue() { return _listValue(); }
Example 15
Source File: User2ServiceImpl.java From transaction-test with MIT License | 4 votes |
@Override @Transactional(propagation = Propagation.REQUIRES_NEW) public void addRequiresNewException(User2 user){ user2Mapper.insert(user); throw new RuntimeException(); }
Example 16
Source File: CheckRepository.java From sitemonitoring-production with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Transactional(propagation = Propagation.REQUIRES_NEW) @Modifying @Query("update Check c set c.currentErrorCount = 0 where c.id = ?1") void clearErrorCount(int checkId);
Example 17
Source File: CheckRepository.java From sitemonitoring-production with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Transactional(propagation = Propagation.REQUIRES_NEW) @Modifying @Query("update Check c set c.lastSentEmail = current_timestamp, currentErrorCount = 0 where c.id = ?1") void emailSent(int checkId);
Example 18
Source File: RuleTagConfigTransactedImpl.java From c2mon with GNU Lesser General Public License v3.0 | 4 votes |
@Override @Transactional(value = "cacheTransactionManager", propagation=Propagation.REQUIRES_NEW, isolation = Isolation.READ_COMMITTED) public void doRemoveRuleTag(final Long id, final ConfigurationElementReport elementReport) { LOGGER.trace("Removing RuleTag " + id); try { RuleTag ruleTag = tagCache.get(id); Collection<Long> ruleIds = ruleTag.getCopyRuleIds(); if (!ruleIds.isEmpty()) { LOGGER.debug("Removing rules dependent on RuleTag " + id); for (Long ruleId : ruleIds) { //concurrent modifcation as a rule is removed from the list during the remove call! if (tagLocationService.isInTagCache(ruleId)) { //may already have been removed if a previous rule in the list was used in this rule! ConfigurationElementReport newReport = new ConfigurationElementReport(Action.REMOVE, Entity.RULETAG, ruleId); elementReport.addSubReport(newReport); ruleTagConfigHandler.removeRuleTag(ruleId, newReport); //call config handler bean so transaction annotation is noticed } } } tagCache.acquireWriteLockOnKey(id); Collection<Long> ruleInputTagIds = Collections.EMPTY_LIST; try { ruleInputTagIds = ruleTag.getCopyRuleInputTagIds(); Collection<Long> alarmIds = ruleTag.getCopyAlarmIds(); if (!alarmIds.isEmpty()) { LOGGER.debug("Removing Alarms dependent on RuleTag " + id); for (Long alarmId : alarmIds) { //need copy as modified concurrently by remove alarm ConfigurationElementReport alarmReport = new ConfigurationElementReport(Action.REMOVE, Entity.ALARM, alarmId); elementReport.addSubReport(alarmReport); alarmConfigHandler.removeAlarm(alarmId, alarmReport); } } for (Long inputTagId : ruleInputTagIds) { tagConfigGateway.removeRuleFromTag(inputTagId, id); //allowed to lock tag below the rule... } for (ConfigurationEventListener listener : configurationEventListeners) { listener.onConfigurationEvent(ruleTag, Action.REMOVE); } configurableDAO.deleteItem(ruleTag.getId()); } catch (RuntimeException rEx) { String errMessage = "Exception caught when removing rule tag with id " + id; LOGGER.error(errMessage, rEx); throw new UnexpectedRollbackException(errMessage, rEx); } finally { if (tagCache.isWriteLockedByCurrentThread(id)) { tagCache.releaseWriteLockOnKey(id); } } } catch (CacheElementNotFoundException e) { LOGGER.debug("Attempting to remove a non-existent RuleTag - no action taken."); elementReport.setWarning("Attempting to removed a non-existent RuleTag"); } }
Example 19
Source File: SubEquipmentConfigTransactedImpl.java From c2mon with GNU Lesser General Public License v3.0 | 4 votes |
@Override @Transactional(value = "cacheTransactionManager", propagation = Propagation.REQUIRES_NEW) public List<ProcessChange> doUpdateAbstractEquipment(final SubEquipment subEquipment, Properties properties) throws IllegalAccessException { return super.updateAbstractEquipment(subEquipment, properties); }
Example 20
Source File: SynchronizerService.java From DataHubSystem with GNU Affero General Public License v3.0 | 3 votes |
/** * Saves the given synchronizer's configuration back in the databse. * This method is intended to be used by Synchronizers themselves, this * method does no tests at all to avoid deadlocks. * <p> * This method is unsafe and you should probably be using * {@link #saveSynchronizerConf(SynchronizerConf)} instead. * @param s to save. */ @Override @Transactional (propagation = Propagation.REQUIRES_NEW) public void saveSynchronizer (Synchronizer s) { this.synchronizerDao.update (s.getSynchronizerConf ()); }