Моя проблема в том, что в моей таблице два простых ключа (теперь нет связи между другой таблицей). Но я не могу получить свои данные. Я использую embeddable для обработки нескольких простых ключей. Все выглядит хорошо. Но когда я использую свой GET в своем RestController, я получаю только ошибку.
Я также попробовал это с IdClass, но у него был тот же результат.
//the shopping card class
@Entity
@Table(name = "shopping_cart")
public class Shopping_Cart {
@EmbeddedId
private Shopping_Cart_Key full_id;
//more variables and getters and setters
//--------------------------
//the key class for the shopping cart
@Embeddable
public class Shopping_Cart_Key implements Serializable {
@Column(name="article_id")
private Integer article_id;
@Column(name="customer_id")
private Integer customer_id;
public Shopping_Cart_Key() {
}
//getters and setters
//-------------------
//the repository
public interface Shopping_CartRepository extends JpaRepository<Shopping_Cart, Integer> {
}
//-----------------------------
//the restController
@RestController
@RequestMapping("/shopping_cart")
public class Shopping_CartController {
@Autowired
Shopping_CartRepository shopping_cartRepository;
@Autowired
CustomerRepository customerRepository;
@Autowired
ArticleRepository articleRepository;
@CrossOrigin
@RequestMapping(method = RequestMethod.GET,
path = "/allshopping_carts",
produces = MediaType.APPLICATION_JSON_VALUE
)
public List<Shopping_Cart> getAllArticles() {
List<Shopping_Cart> Shopping_CartList = shopping_cartRepository.findAll();
return Shopping_CartList;
}
Мой тест:
http://localhost:8080/shopping_cart/allshopping_carts
{
"timestamp": "2019-11-03T16:45:33.293+0000",
"status": 500,
"error": "Internal Server Error",
"message": "could not execute query; nested exception is org.hibernate.exception.GenericJDBCException: could not execute query",
"path": "/shopping_cart/allshopping_carts"
}