org.springframework.transaction.annotation.Transactional Java Examples
The following examples show how to use
org.springframework.transaction.annotation.Transactional.
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: UacMenuServiceImpl.java From paascloud-master with Apache License 2.0 | 6 votes |
@Override @Transactional(readOnly = true, rollbackFor = Exception.class) public ViewMenuVo getViewVoById(Long id) { Preconditions.checkArgument(id != null, "菜单ID不能为空"); UacMenu menu = uacMenuMapper.selectByPrimaryKey(id); if (menu == null) { logger.error("找不到菜单信息id={}", id); throw new UacBizException(ErrorCodeEnum.UAC10013003, id); } // 获取父级菜单信息 UacMenu parentMenu = uacMenuMapper.selectByPrimaryKey(menu.getPid()); ModelMapper modelMapper = new ModelMapper(); ViewMenuVo menuVo = modelMapper.map(menu, ViewMenuVo.class); if (parentMenu != null) { menuVo.setParentMenuName(parentMenu.getMenuName()); } return menuVo; }
Example #2
Source File: JeecgDemoServiceImpl.java From jeecg-boot-with-activiti with MIT License | 6 votes |
/** * 事务控制在service层面 * 加上注解:@Transactional,声明的方法就是一个独立的事务(有异常DB操作全部回滚) */ @Override @Transactional public void testTran() { JeecgDemo pp = new JeecgDemo(); pp.setAge(1111); pp.setName("测试事务 小白兔 1"); jeecgDemoMapper.insert(pp); JeecgDemo pp2 = new JeecgDemo(); pp2.setAge(2222); pp2.setName("测试事务 小白兔 2"); jeecgDemoMapper.insert(pp2); Integer.parseInt("hello");//自定义异常 JeecgDemo pp3 = new JeecgDemo(); pp3.setAge(3333); pp3.setName("测试事务 小白兔 3"); jeecgDemoMapper.insert(pp3); return ; }
Example #3
Source File: RepositoryCopier.java From molgenis with GNU Lesser General Public License v3.0 | 6 votes |
@Transactional public Repository<Entity> copyRepository( Repository<Entity> repository, String entityTypeId, Package pack, String entityTypeLabel) { LOG.info( "Creating a copy of {} repository, with id: {}, package: {} and label: {}", repository.getName(), entityTypeId, pack, entityTypeLabel); // create copy of entity meta data EntityType emd = EntityType.newInstance(repository.getEntityType(), DEEP_COPY_ATTRS, attrFactory); emd.setId(entityTypeId); emd.setLabel(entityTypeLabel); emd.setPackage(pack); // create repository for copied entity meta data Repository<Entity> repositoryCopy = metaDataService.createRepository(emd); // copy data to new repository repositoryCopy.add(repository.query().findAll()); return repositoryCopy; }
Example #4
Source File: Kost1Dao.java From projectforge-webapp with GNU General Public License v3.0 | 6 votes |
/** * Gets kost1 as string. Extends access: Users have read access to the number of their own kost1. * @param id * @return */ @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) public String getKostString(final Integer id) { if (id == null) { return ""; } final Kost1DO kost1 = internalGetById(id); if (kost1 == null) { return ""; } if (hasLoggedInUserSelectAccess(kost1, false) == true) { return KostFormatter.format(kost1); } else { final EmployeeDO employee = userGroupCache.getEmployee(PFUserContext.getUserId()); if (employee != null && employee.getKost1Id() != null && employee.getKost1Id().compareTo(id) == 0) { kost1.setDescription(""); // Paranoia (if KostFormatter shows description in future times and Kost1DO is not visible for the user). return KostFormatter.format(kost1); } } return null; }
Example #5
Source File: VmDeleteVolumeFlow.java From zstack with Apache License 2.0 | 6 votes |
@Transactional private void detachDataVolumes(VmInstanceSpec spec) { List<String> dataVolumeUuids = CollectionUtils.transformToList(spec.getVmInventory().getAllVolumes(), new Function<String, VolumeInventory>() { @Override public String call(VolumeInventory arg) { return VolumeType.Data.toString().equals(arg.getType()) ? arg.getUuid() : null; } }); if (dataVolumeUuids == null || dataVolumeUuids.isEmpty()) { return; } //NOTE(weiw): not using batch sql to avoid deadlock for (String volumeUuid: dataVolumeUuids) { String sql = "update VolumeVO vol set vol.vmInstanceUuid = null where vol.uuid in (:uuids)"; Query q = dbf.getEntityManager().createQuery(sql); q.setParameter("uuids", volumeUuid); q.executeUpdate(); } }
Example #6
Source File: BadgeResourceIntTest.java From TeamDojo with Apache License 2.0 | 6 votes |
@Test @Transactional public void updateNonExistingBadge() throws Exception { int databaseSizeBeforeUpdate = badgeRepository.findAll().size(); // Create the Badge BadgeDTO badgeDTO = badgeMapper.toDto(badge); // If the entity doesn't have an ID, it will be created instead of just being updated restBadgeMockMvc.perform(put("/api/badges") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(badgeDTO))) .andExpect(status().isCreated()); // Validate the Badge in the database List<Badge> badgeList = badgeRepository.findAll(); assertThat(badgeList).hasSize(databaseSizeBeforeUpdate + 1); }
Example #7
Source File: SystemBeanHelpLogicServiceImpl.java From bamboobsc with Apache License 2.0 | 6 votes |
@ServiceMethodAuthority(type={ServiceMethodType.INSERT}) @Transactional( propagation=Propagation.REQUIRED, readOnly=false, rollbackFor={RuntimeException.class, IOException.class, Exception.class} ) @Override public DefaultResult<SysBeanHelpExprMapVO> createExprMap( SysBeanHelpExprMapVO beanHelpExprMap, String helpExprOid) throws ServiceException, Exception { if (beanHelpExprMap==null || super.isBlank(helpExprOid)) { throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK)); } SysBeanHelpExprVO sysBeanHelpExpr = new SysBeanHelpExprVO(); sysBeanHelpExpr.setOid(helpExprOid); DefaultResult<SysBeanHelpExprVO> mResult = this.sysBeanHelpExprService.findObjectByOid(sysBeanHelpExpr); if (mResult.getValue()==null) { throw new ServiceException(mResult.getSystemMessage().getValue()); } sysBeanHelpExpr = mResult.getValue(); // 查看有沒有資料 beanHelpExprMap.setHelpExprOid( sysBeanHelpExpr.getOid() ); return this.sysBeanHelpExprMapService.saveObject(beanHelpExprMap); }
Example #8
Source File: UserDetailsServiceImpl.java From Spring-Security-Third-Edition with MIT License | 6 votes |
@Override @Transactional(readOnly = true) public UserDetails loadUserByUsername(final String username) throws UsernameNotFoundException { CalendarUser user = userRepository.findByEmail(username); if (user == null) throw new UsernameNotFoundException("username " + username + " not found"); Set<GrantedAuthority> grantedAuthorities = new HashSet<>(); for (Role role : user.getRoles()){ grantedAuthorities.add(new SimpleGrantedAuthority(role.getName())); } return new org.springframework.security.core.userdetails.User(user.getEmail(), user.getPassword(), grantedAuthorities); }
Example #9
Source File: JPAAnyObjectDAO.java From syncope with Apache License 2.0 | 6 votes |
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true) @Override @SuppressWarnings("unchecked") public List<Group> findDynGroups(final String key) { Query query = entityManager().createNativeQuery( "SELECT group_id FROM " + JPAGroupDAO.ADYNMEMB_TABLE + " WHERE any_id=?"); query.setParameter(1, key); List<Group> result = new ArrayList<>(); query.getResultList().stream().map(resultKey -> resultKey instanceof Object[] ? (String) ((Object[]) resultKey)[0] : ((String) resultKey)). forEach(groupKey -> { Group group = groupDAO.find(groupKey.toString()); if (group == null) { LOG.error("Could not find group {}, even though returned by the native query", groupKey); } else if (!result.contains(group)) { result.add(group); } }); return result; }
Example #10
Source File: FollowServiceBean.java From bbs with GNU Affero General Public License v3.0 | 6 votes |
/** * 根据用户名称查询粉丝数量 * @param userId 用户Id * @param userName 用户名称 * @return */ @Transactional(readOnly=true, propagation=Propagation.NOT_SUPPORTED) public Long findFollowerCountByUserName(Long userId,String userName){ Long count = 0L; //表编号 int tableNumber = followerConfig.userIdRemainder(userId); Query query = null; if(tableNumber == 0){//默认对象 query = em.createQuery("select count(o) from Follower o where o.userName=?1"); query.setParameter(1, userName); count = (Long)query.getSingleResult(); }else{//带下划线对象 query = em.createQuery("select count(o) from Follower_"+tableNumber+" o where o.userName=?1"); query.setParameter(1, userName); count = (Long)query.getSingleResult(); } return count; }
Example #11
Source File: TelemetryServiceImpl.java From webanno with Apache License 2.0 | 6 votes |
@Override @Transactional public <T> Optional<TelemetrySettings> readSettings(TelemetrySupport<T> aSupport) { String query = "FROM TelemetrySettings " + "WHERE support = :support"; List<TelemetrySettings> results = entityManager.createQuery(query, TelemetrySettings.class) .setParameter("support", aSupport.getId()) .getResultList(); if (results.isEmpty()) { return Optional.empty(); } return Optional.of(results.get(0)); }
Example #12
Source File: SinkResourceIT.java From alchemy with Apache License 2.0 | 6 votes |
@Test @Transactional public void createSinkWithExistingId() throws Exception { int databaseSizeBeforeCreate = sinkRepository.findAll().size(); // Create the Sink with an existing ID sink.setId(1L); SinkDTO sinkDTO = sinkMapper.toDto(sink); // An entity with an existing ID cannot be created, so this API call must fail restSinkMockMvc.perform(post("/api/sinks") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(sinkDTO))) .andExpect(status().isBadRequest()); // Validate the Sink in the database List<Sink> sinkList = sinkRepository.findAll(); assertThat(sinkList).hasSize(databaseSizeBeforeCreate); }
Example #13
Source File: UserService.java From dubai with MIT License | 5 votes |
@Transactional(readOnly = false) public void activeUser(String key) { User user = userRepository.findByActKey(key); if (user == null || DateUtils.truncatedCompareTo(Calendar.getInstance().getTime(), user.getActKeyGenDate(), Calendar.HOUR) > 24 || DateUtils.truncatedCompareTo(user.getActDate(), user.getActKeyGenDate(), Calendar.MILLISECOND) > 0) { throw new ServiceException("激活码错误或者已失效。"); } user.setStatusCode(UserStatus.Active.code()); user.setActDate(Calendar.getInstance().getTime()); userRepository.save(user); }
Example #14
Source File: QuRadioManagerImpl.java From DWSurvey with GNU Affero General Public License v3.0 | 5 votes |
@Override @Transactional public void saveAttr(String quItemId, String isNote) { QuRadio quRadio=get(quItemId); if(isNote!=null && "1".equals(isNote)){ quRadio.setIsNote(1); }else{ quRadio.setIsNote(0); } quRadioDao.save(quRadio); }
Example #15
Source File: ProductRepresentationService.java From ecommerce-product-service with Apache License 2.0 | 5 votes |
@Transactional(readOnly = true) public PagedResource<ProductSummaryRepresentation> listProducts(int pageIndex, int pageSize) { MapSqlParameterSource parameters = new MapSqlParameterSource(); parameters.addValue("limit", pageSize); parameters.addValue("offset", (pageIndex - 1) * pageSize); List<ProductSummaryRepresentation> products = jdbcTemplate.query(SELECT_SQL, parameters, (rs, rowNum) -> new ProductSummaryRepresentation(rs.getString("ID"), rs.getString("NAME"), rs.getBigDecimal("PRICE"))); int total = jdbcTemplate.queryForObject(COUNT_SQL, newHashMap(), Integer.class); return PagedResource.of(total, pageIndex, products); }
Example #16
Source File: DesignatedHostAllocatorFlow.java From zstack with Apache License 2.0 | 5 votes |
@Transactional(readOnly = true) private List<HostVO> allocate(String zoneUuid, String clusterUuid, String hostUuid, String hypervisorType) { StringBuilder sql = new StringBuilder(); sql.append("select h from HostVO h where "); if (zoneUuid != null) { sql.append(String.format("h.zoneUuid = '%s' and ", zoneUuid)); } if (clusterUuid != null) { sql.append(String.format("h.clusterUuid = '%s' and ", clusterUuid)); } if (hostUuid != null) { sql.append(String.format("h.uuid = '%s' and ", hostUuid)); } if (hypervisorType != null) { sql.append(String.format("h.hypervisorType = '%s' and ", hypervisorType)); } sql.append(String.format("h.status = '%s' and h.state = '%s'", HostStatus.Connected, HostState.Enabled)); logger.debug("DesignatedHostAllocatorFlow sql: " + sql); TypedQuery<HostVO> query = dbf.getEntityManager().createQuery(sql.toString(), HostVO.class); if (usePagination()) { query.setFirstResult(paginationInfo.getOffset()); query.setMaxResults(paginationInfo.getLimit()); } return query.getResultList(); }
Example #17
Source File: CityDaoTest.java From fountain with Apache License 2.0 | 5 votes |
@Test @Transactional(propagation = Propagation.NESTED) public void testDelete() { cityService.createCities(5); cityService.deleteCityByIds(CityHelper.getMultipleCityIds(2)); List<City> cities = cityService.getAll(); assertThat(cities.size(), is(3)); }
Example #18
Source File: JpaSoftwareModuleTypeManagement.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
@Override @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) public void delete(final Collection<Long> ids) { final List<JpaSoftwareModuleType> setsFound = softwareModuleTypeRepository.findAllById(ids); if (setsFound.size() < ids.size()) { throw new EntityNotFoundException(SoftwareModuleType.class, ids, setsFound.stream().map(SoftwareModuleType::getId).collect(Collectors.toList())); } softwareModuleTypeRepository.deleteAll(setsFound); }
Example #19
Source File: RoleService.java From momo-cloud-permission with Apache License 2.0 | 5 votes |
/** * 角色状态 * * @param roleReq * @return */ @Transactional public String updateState(RoleReq roleReq) { RoleDO roleDO = roleMapper.selectByPrimaryUuid(roleReq.getUuid()); if (null == roleDO) { throw BizException.fail("待编辑的角色不存在"); } RedisUser redisUser = this.redisUser(); //非总部,不可以操作管理员敏感权限 if (!redisUser.getTenantId().equals(superAdminsService.getTeantId()) && roleDO.getSysRoleType().equals(0)) { throw BizException.fail("您无权限操作"); } RoleDO record = new RoleDO(); //状态 0启用 1禁用 if (roleReq.getDisabledFlag().equals(DisabledFlagEnum.start.type)) { record.setDisabledFlag(DisabledFlagEnum.start.type); } else if (roleReq.getDisabledFlag().equals(DisabledFlagEnum.disabled.type)) { record.setDisabledFlag(DisabledFlagEnum.disabled.type); } record.setUpdateBy(redisUser.getSysUserName()); record.setUpdateTime(DateUtils.getDateTime()); record.setTenantId(roleDO.getTenantId()); record.setId(roleDO.getId()); roleMapper.updateByPrimaryKeySelective(record); roleRedisCacheServiceAsync.roleStatusToRedis(roleDO, record.getDisabledFlag()); return "变更角色状态成功"; }
Example #20
Source File: UserResource.java From OpenIoE with Apache License 2.0 | 5 votes |
/** * PUT /users : Updates an existing User. * * @param managedUserDTO the user to update * @return the ResponseEntity with status 200 (OK) and with body the updated user, * or with status 400 (Bad Request) if the login or email is already in use, * or with status 500 (Internal Server Error) if the user couldnt be updated */ @RequestMapping(value = "/users", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) @Timed @Transactional @Secured(AuthoritiesConstants.ADMIN) public ResponseEntity<ManagedUserDTO> updateUser(@RequestBody ManagedUserDTO managedUserDTO) { log.debug("REST request to update User : {}", managedUserDTO); Optional<User> existingUser = userRepository.findOneByEmail(managedUserDTO.getEmail()); if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserDTO.getId()))) { return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert("userManagement", "emailexists", "E-mail already in use")).body(null); } existingUser = userRepository.findOneByLogin(managedUserDTO.getLogin().toLowerCase()); if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserDTO.getId()))) { return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert("userManagement", "userexists", "Login already in use")).body(null); } return userRepository .findOneById(managedUserDTO.getId()) .map(user -> { user.setLogin(managedUserDTO.getLogin()); user.setFirstName(managedUserDTO.getFirstName()); user.setLastName(managedUserDTO.getLastName()); user.setEmail(managedUserDTO.getEmail()); user.setActivated(managedUserDTO.isActivated()); user.setLangKey(managedUserDTO.getLangKey()); Set<Authority> authorities = user.getAuthorities(); authorities.clear(); managedUserDTO.getAuthorities().stream().forEach( authority -> authorities.add(authorityRepository.findOne(authority)) ); return ResponseEntity.ok() .headers(HeaderUtil.createAlert("userManagement.updated", managedUserDTO.getLogin())) .body(new ManagedUserDTO(userRepository .findOne(managedUserDTO.getId()))); }) .orElseGet(() -> new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR)); }
Example #21
Source File: MemberServiceImpl.java From product-recommendation-system with MIT License | 5 votes |
@Override @Transactional(isolation=Isolation.DEFAULT, propagation = Propagation.REQUIRED) public boolean updatePassword(Long memberId, String oldPassword, String newPassword, String confirmPassword) { // 1.确定密码用户id是否为空 if (StringUtils.isEmpty(oldPassword) || StringUtils.isEmpty(newPassword) || StringUtils.isEmpty(confirmPassword) || memberId == null) { return false; } // 2.确定旧密码是否正确 String dbPassword = this.memberMapper.getMemberByMemberId(memberId).getPassword(); boolean flag = this.validatePsd(oldPassword, dbPassword); if (!flag) { return false; } // 3.确定两次输入的新密码是否一致 if (!newPassword.equals(confirmPassword)) { return false; } // 将密码加下密 String encryptPassword = encryptPsd(newPassword); int rows = this.memberMapper.updatePassword(memberId, encryptPassword); if (rows > 0) { return true; } return false; }
Example #22
Source File: DepotItemService.java From jshERP with GNU General Public License v3.0 | 5 votes |
@Transactional(value = "transactionManager", rollbackFor = Exception.class) public int batchDeleteDepotItemByIds(String ids)throws Exception { User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); int result =0; try{ result =depotItemMapperEx.batchDeleteDepotItemByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); }catch(Exception e){ JshException.writeFail(logger, e); } return result; }
Example #23
Source File: DefaultIdentifiableObjectManager.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override @Transactional( readOnly = true ) @SuppressWarnings( "unchecked" ) public <T extends DimensionalObject> List<T> getDataDimensionsNoAcl( Class<T> clazz ) { GenericDimensionalObjectStore<DimensionalObject> store = getDimensionalObjectStore( clazz ); if ( store == null ) { return new ArrayList<>(); } return (List<T>) store.getByDataDimensionNoAcl( true ); }
Example #24
Source File: BranchService.java From mojito with Apache License 2.0 | 5 votes |
@Transactional public void deleteBranch(Long repositoryId, Long branchId) { deleteBranchAsset(branchId, repositoryId); Branch branch = branchRepository.findOne(branchId); logger.debug("Mark branch {} as deleted", branch.getName()); branch.setDeleted(true); branchRepository.save(branch); }
Example #25
Source File: QuoteResourceIntTest.java From tutorials with MIT License | 5 votes |
@Test @Transactional public void getAllQuotesByPriceIsEqualToSomething() throws Exception { // Initialize the database quoteRepository.saveAndFlush(quote); // Get all the quoteList where price equals to DEFAULT_PRICE defaultQuoteShouldBeFound("price.equals=" + DEFAULT_PRICE); // Get all the quoteList where price equals to UPDATED_PRICE defaultQuoteShouldNotBeFound("price.equals=" + UPDATED_PRICE); }
Example #26
Source File: BumblebeeServiceImpl.java From bumblebee with Apache License 2.0 | 5 votes |
@Override @Transactional(rollbackFor = Exception.class) public String delGroup(Integer groupId) { if(null==groupId){ return "fail"; } //删除组 bumblebeeDao.delGroup(groupId); //设置用户组为null bumblebeeDao.updateUserGroup(groupId); //删除组绑定的权限 bumblebeeDao.delPermission(groupId); return "fail"; }
Example #27
Source File: ExamServiceImpl.java From ExamStack with GNU General Public License v2.0 | 5 votes |
@Transactional @Override public void addExamUser(int examId,String userNameStr,HashMap<String,Role> roleMap){ try { String[] userNames = userNameStr.split(";"); List<User> userList = userMapper.getUserByNames(userNames, roleMap.get("ROLE_STUDENT").getRoleId()); Exam exam = examMapper.getExamById(examId); ExamPaper examPaper = examPaperMapper.getExamPaperById(exam.getExamPaperId()); SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd"); Date now = new Date(); for(User user : userList){ ExamHistory history = this.getUserExamHistByUserIdAndExamId(user.getUserId(), examId, 0,1,2,3); if(history == null){ history = new ExamHistory(); history.setExamId(exam.getExamId()); history.setExamPaperId(exam.getExamPaperId()); history.setContent(examPaper.getContent()); history.setDuration(examPaper.getDuration()); //默认创建的记录都是审核通过的 history.setApproved(1); String seriNo = sdf.format(now) + StringUtil.format(user.getUserId(), 3) + StringUtil.format(exam.getExamId(), 3); history.setSeriNo(seriNo); history.setVerifyTime(new Date()); history.setUserId(user.getUserId()); examMapper.addUserExamHist(history); }else if(history.getApproved() == 0){ //审核状态是0的才允许重新添加 examMapper.deleteUserExamHistByUserId(exam.getExamId(),user.getUserId()); //批量添加的都是审核通过的记录 history.setApproved(1); examMapper.addUserExamHist(history); } } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); throw new RuntimeException(e); } }
Example #28
Source File: VerifyCodeResourceIntTest.java From cubeai with Apache License 2.0 | 5 votes |
@Test @Transactional public void getVerifyCode() throws Exception { // Initialize the database verifyCodeRepository.saveAndFlush(verifyCode); // Get the verifyCode restVerifyCodeMockMvc.perform(get("/api/verify-codes/{id}", verifyCode.getId())) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.id").value(verifyCode.getId().intValue())) .andExpect(jsonPath("$.code").value(DEFAULT_CODE.toString())) .andExpect(jsonPath("$.expire").value(DEFAULT_EXPIRE.toString())); }
Example #29
Source File: DepartmentService.java From smart-admin with MIT License | 5 votes |
/** * 新增添加部门 * * @param departmentCreateDTO * @return AjaxResult */ @Transactional(rollbackFor = Exception.class) public ResponseDTO<String> addDepartment(DepartmentCreateDTO departmentCreateDTO) { DepartmentEntity departmentEntity = SmartBeanUtil.copy(departmentCreateDTO, DepartmentEntity.class); departmentEntity.setSort(0L); departmentDao.insert(departmentEntity); departmentEntity.setSort(departmentEntity.getId()); departmentDao.updateById(departmentEntity); return ResponseDTO.succ(); }
Example #30
Source File: AccountService.java From Oauth2-Stateless-Authentication-with-Spring-and-JWT-Token with MIT License | 5 votes |
@Transactional // To successfully remove the date @Transactional annotation must be added public void removeAuthenticatedAccount() throws UsernameNotFoundException { String username = SecurityContextHolder.getContext().getAuthentication().getName(); Account acct = findAccountByUsername(username); accountRepo.deleteAccountById(acct.getId()); }