"Could not write JSON: class java.util.ArrayList cannot be cast to class org.hibernate.mapping.List

tried to make i api call for allorders and orsderbyuserid but now i broke both:boohoo:
6 Replies
JavaBot
JavaBot10mo ago
This post has been reserved for your question.
Hey @timo! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Timo
TimoOP10mo ago
Could not write JSON: class java.util.ArrayList cannot be cast to class org.hibernate.mapping.List (java.util.ArrayList is in module java.base of loader 'bootstrap'; org.hibernate.mapping.List is in unnamed module of loader 'app')
Timo
TimoOP10mo ago
No description
Timo
TimoOP10mo ago
@RequestMapping("/orders")
public class OrderController {
private final OrderService orderService;

@Autowired
public OrderController(OrderService orderService) {
this.orderService = orderService;
}

@PostMapping
public ResponseEntity<Order> placeOrder(@RequestBody OrderDTO orderDTO, Principal principal) throws Exception {
if (principal == null) throw new Exception();
return ok(orderService.placeOrder(orderDTO, principal.getName()));
}

@GetMapping("/history")
public ResponseEntity<List<HistoryOrderDTO>> getOrderHistory(Principal principal) throws Exception {
if (principal == null) throw new Exception();
return ok(orderService.findOrdersByCustomUser(principal.getName()));

}

@DeleteMapping("/{id}")
public ResponseEntity<String> deleteById(@PathVariable Long id){
this.orderService.deleteById(id);
return ok("Order deleted with id " + id);
}
}
@RequestMapping("/orders")
public class OrderController {
private final OrderService orderService;

@Autowired
public OrderController(OrderService orderService) {
this.orderService = orderService;
}

@PostMapping
public ResponseEntity<Order> placeOrder(@RequestBody OrderDTO orderDTO, Principal principal) throws Exception {
if (principal == null) throw new Exception();
return ok(orderService.placeOrder(orderDTO, principal.getName()));
}

@GetMapping("/history")
public ResponseEntity<List<HistoryOrderDTO>> getOrderHistory(Principal principal) throws Exception {
if (principal == null) throw new Exception();
return ok(orderService.findOrdersByCustomUser(principal.getName()));

}

@DeleteMapping("/{id}")
public ResponseEntity<String> deleteById(@PathVariable Long id){
this.orderService.deleteById(id);
return ok("Order deleted with id " + id);
}
}
just seems to break to my ordercontroller in genera; i fixed it guess im him
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
JavaBot
JavaBot10mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?