List of usage examples for org.springframework.transaction.annotation Propagation REQUIRES_NEW
Propagation REQUIRES_NEW
To view the source code for org.springframework.transaction.annotation Propagation REQUIRES_NEW.
Click Source Link
From source file:es.emergya.bbdd.dao.CapaInformacionHome.java
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false, rollbackFor = Throwable.class) public boolean saveOrUpdate(CapaInformacion p) { if (p == null) { return false; }/* w w w. j ava2 s. c om*/ CapaInformacion entity = null; try { Session currentSession = getSession(); if (p.getId() != null && this.get(p.getId()) != null) { entity = (CapaInformacion) currentSession.merge(p); } if (entity == null) { entity = p; } if (p.getOrden() == null && entity.getOrden() == null) { entity.setOrden(getTotal() + 1); } currentSession.saveOrUpdate(entity); return true; } catch (Throwable t) { log.error(t, t); return false; } }
From source file:com.netsteadfast.greenstep.bsc.service.logic.impl.PerspectiveLogicServiceImpl.java
@ServiceMethodAuthority(type = { ServiceMethodType.SELECT }) @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true) @Override/*from ww w . java2s.c o m*/ public String findForMaxPerId(String date) throws ServiceException, Exception { if (super.isBlank(date) || !NumberUtils.isNumber(date) || date.length() != 8) { throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK)); } String maxVisionId = this.perspectiveService.findForMaxPerId(BscConstants.HEAD_FOR_PER_ID + date); if (StringUtils.isBlank(maxVisionId)) { return BscConstants.HEAD_FOR_PER_ID + date + "001"; } int maxSeq = Integer.parseInt(maxVisionId.substring(11, 14)) + 1; if (maxSeq > 999) { throw new ServiceException( SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS) + " over max seq 999!"); } return BscConstants.HEAD_FOR_PER_ID + date + StringUtils.leftPad(String.valueOf(maxSeq), 3, "0"); }
From source file:es.emergya.bbdd.dao.ClienteConectadoHome.java
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false, rollbackFor = Throwable.class) public boolean updateLastConnected(long fsUid) { log.debug("Actualizando la fecha de ltima conexin de la EF " + fsUid); String hql = "update ClienteConectado set ultimaConexion = now() where id = :FSUID"; boolean result = false; Query query = getSession().createQuery(hql); query.setLong("FSUID", fsUid); int rowsUpdated = query.executeUpdate(); if (rowsUpdated == 0) { result = false;/*ww w . ja va 2 s . c o m*/ } else { result = true; } return result; }
From source file:es.emergya.bbdd.dao.PatrullaHome.java
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true, rollbackFor = Throwable.class) public Patrulla find(String p) { Patrulla res = null;/*from w w w .j a v a2 s. com*/ try { Session currentSession = getSession(); currentSession.clear(); res = (Patrulla) currentSession.createCriteria(Patrulla.class).add(Restrictions.ilike("nombre", p)) .setMaxResults(1).uniqueResult(); } catch (Throwable t) { log.error(t, t); } return res; }
From source file:org.brekka.pegasus.core.services.impl.AllocationServiceImpl.java
@Override @Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.REPEATABLE_READ) public void forceExpireAllocation(final Allocation allocation) { Date expiryDate = new Date(); // Update the incoming reference with the date allocation.setExpires(expiryDate);// ww w .j av a2 s . c o m Allocation managed = this.allocationDAO.retrieveById(allocation.getId()); managed.setExpires(expiryDate); this.allocationDAO.update(managed); }
From source file:com.google.ie.business.service.impl.ShardedCounterServiceImpl.java
@Override @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW) public void incrementPositivePoints(String parentKey) { logger.debug("Incrementing positive point in sharded counter for parent key: " + parentKey); if (parentKey == null) { logger.debug("Parent key value is null : "); return;//from ww w . ja v a 2 s . co m } Random generator = new Random(); int shardNum = generator.nextInt(DaoConstants.SHARDED_COUNTERS); List<ShardedCounter> shards = shardedCounterDao.getShardsByParentKeyAndShardNum(parentKey, shardNum); ShardedCounter shard = null; ShardedCounter shardToUpdate = null; if (shards == null || shards.isEmpty()) { shardToUpdate = new ShardedCounter(parentKey); shardToUpdate.setPositivePoint(DaoConstants.ONE); shardToUpdate.setShardNumber(shardNum); } else { shard = shards.get(0); shardToUpdate = getShardCopy(shard); shardToUpdate.setPositivePoint(shardToUpdate.getPositivePoint() + DaoConstants.ONE); } shardedCounterDao.createOrUpdateShardedCounter(shardToUpdate); logger.debug("Negative point incremented in sharded counter for parent key : " + parentKey); }
From source file:bean.RedSocial.java
/** * // w w w. j ava 2s . c o m * @return */ @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false, rollbackFor = transactionalBusinessException.GetUsuarioConectadoException.class) public Usuario getUsuarioConectado() { usuarioConectado = daoUsuario.obtenerUsuario(username); return usuarioConectado; }
From source file:net.rrm.ehour.timesheet.service.TimesheetPersistance.java
@Transactional(rollbackFor = OverBudgetException.class, propagation = Propagation.REQUIRES_NEW) @NonAuditable/*from w w w .ja v a2 s. c om*/ public void validateAndPersist(ProjectAssignment assignment, List<TimesheetEntry> entries, DateRange weekRange, List<Date> lockedDates) throws OverBudgetException { ProjectAssignmentStatus beforeStatus = projectAssignmentStatusService.getAssignmentStatus(assignment); boolean checkAfterStatus = beforeStatus.isValid(); try { persistEntries(assignment, entries, weekRange, !beforeStatus.isValid(), lockedDates); } catch (OverBudgetException obe) { // make sure it's retrown by checking the after status checkAfterStatus = true; } ProjectAssignmentStatus afterStatus = projectAssignmentStatusService.getAssignmentStatus(assignment); if (checkAfterStatus && !afterStatus.isValid()) { throw new OverBudgetException(afterStatus); } else if (!beforeStatus.equals(afterStatus) && canNotifyPm(assignment)) { notifyPm(assignment, afterStatus); } }
From source file:architecture.ee.web.community.streams.DefaultPhotoStreamsManager.java
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW) public void deletePhotos(Image image, User creator) { List<Photo> list = getPhotosByImage(image); streamsDao.removePhotos(image);// w ww .ja v a2s.c o m for (Photo p : list) photoStreamCache.remove(p.getExternalId()); }
From source file:es.emergya.bbdd.dao.IncidenciaHome.java
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false, rollbackFor = Throwable.class) public boolean delete(Incidencia r) { if (r == null || r.getId() == null) return false; try {/*from w ww . j a v a2 s .co m*/ this.remove(r.getId()); } catch (Throwable t) { log.error(t, t); return false; } return true; }