Wie Zum Einfügen Von Daten In Mehreren Tabellen Mit Foreign Key-Spring Boot Java-MySQL

Ich versuche, zu schaffen Kassensystem mit Spring Boot und JavaFX. Dann habe ich normalisierte meinen Tabellen. Dann erstelle ich Haupttabelle --> "Item-Tabelle" und sub-Tabelle --> "Lieferanten","Artikel-Kategorie", Artikel-Marke",..... So, ich konnte verbinden Sie einen sub-Tabelle Item Tabelle, ich kann nicht verbinden alle sub-Tabellen Tabelle "Artikel".

Ich benutze @ManyToOne zwischen diesen Tabellen.

"Item-Tabelle"

@Entity
@Table(name="Item")
public class Item {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "item_serial_number_id", nullable = false)
    private int item_serial_number_id;

    private String item_serial_number;

    @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinColumn(name = "item_brand_id")
    private Item_Brand item_brand_map;

    @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinColumn(name = "supplier_id")
    private Supplier supplier_map;

    @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinColumn(name = "item_category_id")
    private Item_Category item_category_map;

    @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinColumn(name = "item_sell_amount_id")
    private Item_Sell_Amount item_sell_amount_map;

    @OneToMany(mappedBy="main_item_map")
    private Set<Main_Table> main_table_item;

    private double item_discounts;
    private double item_buy_amount;
    private String item_warranty_hardware;
    private String item_warranty_software;
    private Blob item_qrcode;
    private boolean item_sold;
    private boolean item_expire;
    private int item_repair;

"Item_Brand" Tabelle

@Entity
@Table(name="Item_Brand")
public class Item_Brand {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "item_brand_id", nullable = false)
    private int item_brand_id;

    private String item_brand_name;

    @OneToMany(mappedBy="item_brand_map",fetch = FetchType.EAGER,cascade = CascadeType.ALL)
    private Set<Item> item_item_brand;

"Item_Sell_Amount" Tabelle

@Entity
@Table(name="Item_Sell_Amount")
public class Item_Sell_Amount {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "item_sell_amount_id", nullable = false)
    private int item_sell_amount_id;

    private double item_sell_amount_value;
    private double item_down_payment;
    private double item_monthly_payment;
    private double item_interes;

Also, Fremde Tabellen-Strukturen dieser Art und Wenn ich das Element speichern, ich benutze diesen code Balg,

Item_Sell_Amount item_sell_amount = getSavedItemSellAmount();

        Item item = new Item();
        item.setItem_serial_number(getSerialNumber());
        item.setItem_category_map(item_category);
        item.setItem_brand_map(item_brand);
        item.setItem_buy_amount(getBuyAmount());
        item.setItem_sell_amount_map(item_sell_amount);
        item.setItem_discounts(getDiscount());
        item.setSupplier_map(supplier);
        item.setItem_warranty_hardware(getHardwareWarranty());
        item.setItem_warranty_software(getSoftwareWarranty());
        item.setItem_qrcode(getQRCodeImage());
        item.setItem_sold(false);
        item.setItem_expire(false);
        //item.setItem_repair(0);

        Set<Item> itemSet = new HashSet();
        itemSet.add(item);
        item_sell_amount.setItem_sell_amount(itemSet);
        item_sell_amountService.save(item_sell_amount);

Element Dienst wie dieser.

@Service
public class ItemServiceImpl implements ItemService {

    @Autowired
    private ItemRepository itemRepository;

    @Override
    public Item save(Item entity) {
        return itemRepository.save(entity);
    }

    @Override
    public Item update(Item entity) {
        return itemRepository.save(entity);
    }

    @Override
    public void delete(Item entity) {
        itemRepository.delete(entity);
    }

    @Override
    public void deleteInBatch(List<Item> items) {
        itemRepository.deleteInBatch(items);
    }

    @Override
    public List<Item> findAll() {
            List<Item> list = new ArrayList<>();
        itemRepository.findAll().forEach(e -> list.add(e));
            return list;
    }

    @Override
    public Item find(int id) {
        //return companyRepository.findOne(id);
        return null;
    }

Wenn ich sparen Sie eine Fremde Tabelle keine Fehler, Aber dieses mal, Fehler Balg,

Caused by: org.springframework.dao.InvalidDataAccessApiUsageException: detached entity passed to persist: