现在,我的数据库有以下(简化)格式:
ShoppingList
{
List<ListProduct> listProducts
}
ListProduct
{
int quantity
Product product
}
Product
{
information about the overall product...
List<StoreProduct> StoreProduct
}
StoreProduct
{
information about the specific product and
我正在使用Java和Spring开发REST来管理采购和客户。在我的MySQL数据库中,我有一个表Purchase,它有一个列来存储唯一的ticketId。这不是主键。
当添加新的采购(通过执行PUT请求)时,我将根据请求中提供的数据创建一个新的采购,获取最大ticketId,将其增加一个,并将其存储在数据库中。主键是自动递增的.
这是我的密码:
@Transactional
public boolean saveNewPurchase(PurchaseDTO data) {
Purchase p = createPurchaseFromData(data);
Long idTicke