This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface SomeHttpClient { | |
| @GetMapping | |
| fun getSomething( | |
| @RequestHeader headers: Map<String, String> = emptyMap(), | |
| @SpringQueryMap @ModelAttribute customObject: Any | |
| ): List<SomeResponse>? | |
| @PostMapping | |
| fun postSomething( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Bean | |
| fun feignClient(): Feign.Builder { | |
| return Feign.builder() | |
| .decoder(GsonDecoder()) | |
| .encoder(GsonEncoder()) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun feignClient(): GitHub { | |
| return Feign.builder() | |
| .decoder(GsonDecoder()) | |
| .encoder(GsonEncoder()) | |
| .target(GitHub.class, "https://api.github.com") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Data | |
| @Entity | |
| @NoArgsConstructor | |
| public class Account { | |
| // Outros campos | |
| @Version | |
| private Long version; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Data | |
| @Entity | |
| @NoArgsConstructor | |
| public class Account { | |
| @Id | |
| @GeneratedValue | |
| private Long id; | |
| private BigDecimal amount; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Autowired | |
| private UserService userService; | |
| @Transactional | |
| public void addBillsNewTransactionByProxy(final Long id, final List<BillVO> billList) { | |
| User user = userRepository.getOne(id); | |
| for (BillVO billVO : billList) { | |
| userService.createBill(billVO, user); | |
| } | |
| throw new RuntimeException(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Transactional | |
| public void addBillsNewTransactionInThisClass(final Long id, final List<BillVO> billList) { | |
| User user = userRepository.getOne(id); | |
| for (BillVO billVO : billList) { | |
| createBill(billVO, user); | |
| } | |
| throw new RuntimeException(); | |
| } | |
| @Transactional(propagation = Propagation.REQUIRES_NEW) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Transactional(noRollbackFor = RuntimeException.class) | |
| public void validateBillWithUncheckedException(BillVO bill) { | |
| if (bill.getDate().isAfter(LocalDate.now())) { | |
| throw new RuntimeException(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Autowired | |
| private ValidationService validationService; | |
| @Transactional | |
| public void addBillsCatchingProxyUncheckedException(final Long id, final List<BillVO> billList) { | |
| User user = userRepository.getOne(id); | |
| for (BillVO billVO : billList) { | |
| try { | |
| validationService.validateBillWithUncheckedException(billVO); | |
| user.getBillList().add( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Transactional | |
| public void addBillsCatchingPrivateUncheckedException(final Long id, final List<BillVO> billList) { | |
| User user = userRepository.getOne(id); | |
| for (BillVO billVO : billList) { | |
| try { | |
| validateBillWithUncheckedException(billVO); | |
| user.getBillList().add( | |
| new Bill(billVO.getType(), | |
| billVO.getValue(), billVO.getDate(), user)); | |
| } catch (RuntimeException e) { |