This commit is contained in:
Алексей Крюков 2024-04-15 15:25:29 +04:00
parent c24dace777
commit cc1a023999
14 changed files with 4 additions and 1 deletions

Binary file not shown.

View File

@ -23,7 +23,7 @@ public class OrderEntity extends BaseEntity {
@JoinColumn()
private UserEntity user;
@JsonManagedReference
@OneToMany(fetch = FetchType.EAGER)
@OneToMany
private final List<OrderLineEntity> lines = new ArrayList<>();
private Double totalPrice;

View File

@ -32,6 +32,7 @@ public class OrderService {
return repository.findAll();
}
@Transactional(readOnly = true)
public OrderEntity get(Long id) {
return repository.findById(id)
.orElseThrow(() -> new NotFoundException(OrderEntity.class, id));
@ -41,6 +42,7 @@ public class OrderService {
return repository.save(entity);
}
@Transactional
public OrderEntity update(Long id, OrderEntity entity) {
final OrderEntity existEntity = get(id);
existEntity.setUser(entity.getUser());
@ -54,6 +56,7 @@ public class OrderService {
return repository.save(existEntity);
}
@Transactional
public OrderEntity delete(Long id) {
final OrderEntity existsEntity = get(id);
repository.delete(existsEntity);