List of usage examples for org.springframework.transaction.annotation Isolation SERIALIZABLE
Isolation SERIALIZABLE
To view the source code for org.springframework.transaction.annotation Isolation SERIALIZABLE.
Click Source Link
From source file:uk.co.parso.barebones.TestServiceImpl.java
@RequestMapping("test") @ResponseStatus(HttpStatus.OK)/*from w w w.jav a 2 s .c o m*/ @Transactional(readOnly = false, isolation = Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @Override public void test() { logger.debug("TEST"); Test test = testRepo.selectForUpdate(1L); Test test2 = testRepo.selectForUpdate(2L); test.setName("test" + (new Date()).getTime()); test.setName("test2" + (new Date()).getTime()); }
From source file:org.devware.batch.dao.Impl.ItemDaoImpl.java
@Transactional(isolation = Isolation.SERIALIZABLE) @Override// ww w . j a va 2s . c om public int deleteAllItem(List<? extends Item> itemList) { int count = 0; // si la liste est vide on retourne 0 if (itemList == null || itemList.isEmpty()) return 0; /* *on parcour la liste en suppression */ for (Item item : itemList) { count += deleteItem(item); } return count; }
From source file:com.aan.girsang.server.service.impl.SecurityServiceImpl.java
@Override @Transactional(isolation = Isolation.SERIALIZABLE) public void simpan(Pengguna p) { if (p.getIdPengguna().equals("")) p.setIdPengguna(runningNumberDao.ambilBerikutnyaDanSimpan(MasterRunningNumberEnum.PENGGUNA)); penggunaDao.simpan(p);//w w w . j a v a 2s. c om }
From source file:com.vladmihalcea.service.impl.StoreServiceImpl.java
@Override @Transactional(isolation = Isolation.SERIALIZABLE) public void purchase(Long productId) { Product product = entityManager.find(Product.class, 1L); Session session = (Session) entityManager.getDelegate(); session.doWork(new Work() { @Override/*w w w . ja v a 2 s.c o m*/ public void execute(Connection connection) throws SQLException { LOGGER.debug("Transaction isolation level is {}", Environment.isolationLevelToString(connection.getTransactionIsolation())); } }); product.setQuantity(product.getQuantity() - 1); }
From source file:fi.hsl.parkandride.back.LockDao.java
@Override @Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.SERIALIZABLE) public Lock acquireLock(String lockName, Duration lockDuration) { Optional<Lock> lock = selectLockIfExists(lockName); if (lock.isPresent()) { Lock existingLock = lock.get(); if (!existingLock.validUntil.isAfter(DateTime.now())) { return claimExpiredLock(existingLock, lockDuration); } else {// w ww .j a v a 2 s .co m throw new LockAcquireFailedException("Existing lock " + existingLock + " is still valid"); } } return insertLock(lockName, lockDuration); }
From source file:com.aan.girsang.server.service.impl.MasterServiceImpl.java
@Override @Transactional(isolation = Isolation.SERIALIZABLE) public void simpan(GolonganBarang golonganBarang) { if (golonganBarang.getId() == null) { golonganBarang.setId(runningNumberDao.ambilBerikutnyaDanSimpan(MasterRunningNumberEnum.GOLONGAN)); }/*from w ww . ja va2s .c om*/ golonganBarangDao.simpan(golonganBarang); }
From source file:com.perceptive.epm.perkolcentral.bl.ImageNowLicenseBL.java
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.SERIALIZABLE, rollbackFor = ExceptionWrapper.class) public void addImageNowLicenseRequest(Imagenowlicenses imagenowlicenses, String groupRequestedFor, String employeeUIDWhoRequestedLicense, File sysfpFile, String originalFileName) throws ExceptionWrapper { try {//w w w.ja va 2 s . co m imageNowLicenseDataAccessor.addImageNowLicense(imagenowlicenses, groupRequestedFor, employeeUIDWhoRequestedLicense); if (!new File(fileUploadPath).exists()) FileUtils.forceMkdir(new File(fileUploadPath)); File filePathForThisRequest = new File( FilenameUtils.concat(fileUploadPath, imagenowlicenses.getImageNowLicenseRequestId())); FileUtils.forceMkdir(filePathForThisRequest); File fileNameToCopy = new File( FilenameUtils.concat(filePathForThisRequest.getAbsolutePath(), originalFileName)); FileUtils.copyFile(sysfpFile, fileNameToCopy); //Send the email String messageToSend = String.format(Constants.email_license_request, imagenowlicenses.getEmployeeByRequestedByEmployeeId().getEmployeeName(), imagenowlicenses.getGroups().getGroupName(), new SimpleDateFormat("dd-MMM-yyyy").format(imagenowlicenses.getLicenseRequestedOn()), imagenowlicenses.getImageNowVersion(), imagenowlicenses.getHostname(), Long.toString(imagenowlicenses.getNumberOfLicenses())); email = new HtmlEmail(); email.setHostName(emailHost); email.setHtmlMsg(messageToSend); email.setSubject("ImageNow License Request"); //email.setFrom("ImageNowLicenseRequest@perceptivesoftware.com", "ImageNow License Request"); email.setFrom("ImageNowLicenseRequest@lexmark.com", "ImageNow License Request"); // Create the attachment EmailAttachment attachment = new EmailAttachment(); attachment.setPath(fileNameToCopy.getAbsolutePath()); attachment.setDisposition(EmailAttachment.ATTACHMENT); attachment.setDescription(originalFileName); attachment.setName(originalFileName); email.attach(attachment); //Send mail to scrum masters for (EmployeeBO item : employeeBL.getAllEmployeesKeyedByGroupId().get(Integer.valueOf("14"))) { email.addTo(item.getEmail(), item.getEmployeeName()); } //email.addTo("saibal.ghosh@perceptivesoftware.com","Saibal Ghosh"); email.addCc(imagenowlicenses.getEmployeeByRequestedByEmployeeId().getEmail()); email.send(); } catch (Exception ex) { throw new ExceptionWrapper(ex); } }
From source file:com.perceptive.epm.perkolcentral.bl.LicensesBL.java
@Transactional(propagation = Propagation.REQUIRED, readOnly = true, isolation = Isolation.SERIALIZABLE, rollbackFor = ExceptionWrapper.class) public ArrayList<LicenseBO> getAllLicenseType() throws ExceptionWrapper { ArrayList<LicenseBO> licenseBOArrayList = new ArrayList<LicenseBO>(); try {//from w w w . j a v a2s . c o m for (Object obj : licenseMasterDataAccessor.getAllLicenseType().values()) { final LicenseBO licenseBO = (LicenseBO) obj; licenseBOArrayList.add(licenseBO); } } catch (Exception ex) { throw new ExceptionWrapper(ex); } return licenseBOArrayList; }
From source file:com.inkubator.hrm.service.impl.SchedulerConfigServiceImpl.java
@Override // Harus serialiasai agar tidak tumpang tindih dengan proses schedulerr yang berjalan @Transactional(readOnly = false, isolation = Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = Exception.class) public void save(SchedulerConfig entity) throws Exception { long totalDuplicates = schedulerConfigDao.getTotalByName(entity.getName()); if (totalDuplicates > 0) { throw new BussinessException("scheduler_config.error_name"); }/*w ww . ja v a2 s. com*/ entity.setId(Long.parseLong(RandomNumberUtil.getRandomNumber(12))); entity.setCreatedBy(UserInfoUtil.getUserName()); entity.setCretedOn(new Date()); if (entity.getIsTimeDiv()) { Date now = new Date(); String nowString = new SimpleDateFormat("dd MM yyyy HH:mm").format(now); // entity.setLastExecution(new SimpleDateFormat("dd MM yyyy HH:mm").parse(nowString)); entity.setLastExecution(DateUtils.truncate(now, Calendar.MINUTE)); } schedulerConfigDao.save(entity); }