Created
July 19, 2020 04:57
-
-
Save hkakutalua/089e7816ab98b63fcbd4166d906ef7ec to your computer and use it in GitHub Desktop.
LazyInitializationException
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
val product = productsRepository.findByIdOrNull(cartItem.productId) | |
if (product == null) { | |
return ResponseEntity.notFound().build() | |
} | |
val cart = cartsRepository.findByIdOrNull(cartId) | |
if (cart == null) { | |
return ResponseEntity.notFound().build() | |
} | |
cart.addProduct(product, cartItem.quantity) | |
cartsRepository.save(cart) // with @Transactional there's no need of this line |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment