Skip to content

Commit

Permalink
update according to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyH277 committed Apr 16, 2024
1 parent 666ae01 commit 742e8e4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/main/java/mate/academy/model/Order.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class Order {
private List<Ticket> tickets;
private LocalDateTime orderDate;
@ManyToOne
@JoinColumn(name = "user_id")
private User user;

public Long getId() {
Expand Down
11 changes: 3 additions & 8 deletions src/main/java/mate/academy/service/impl/OrderServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,9 @@ public Order completeOrder(ShoppingCart shoppingCart) {
order.setOrderDate(LocalDateTime.now());
order.setTickets(List.copyOf(shoppingCart.getTickets()));
order.setUser(shoppingCart.getUser());
try {
orderDao.add(order);
shoppingCartService.clearShoppingCart(shoppingCart);
return order;
} catch (Exception e) {
throw new RuntimeException("Can't complete order from shopping cart "
+ shoppingCart, e);
}
orderDao.add(order);
shoppingCartService.clearShoppingCart(shoppingCart);
return order;
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/hibernate.cfg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
<mapping class="mate.academy.model.ShoppingCart"/>
<mapping class="mate.academy.model.Order"/>
</session-factory>
</hibernate-configuration>
</hibernate-configuration>

0 comments on commit 742e8e4

Please sign in to comment.