I recently used Mysql to connect to hibernate, and the generation policy is "identity". I encountered problems when adding data, such as adding a reimbursement form table and a reimbursement schedule (the relationship between the reimbursement form and reimbursement details is one-to-many, cascade & quot; all & quot;) is set in the reimbursement form. each time the data of the report object is saved, you will find that the reimbursement details in the last saved reimbursement form are saved to the object of this saved reimbursement form. After debugging, it is found that every time the program automatically sends the id of the report object to the ID value of the last inserted, and then the id is + 1 when the database is actually inserted, the reimbursement details object then changes the last foreign key value id to id + 1. what is the solution? Whether the primary key is mysqlhibernate database
I recently used Mysql to connect to hibernate, and the generation policy is "identity". I encountered problems when adding data, such as adding a reimbursement form table and a reimbursement schedule (the relationship between the reimbursement form and reimbursement details is one-to-many, cascade = "all") is set in the reimbursement form. each time you save the data of the report object, you will find that the reimbursement details in the last saved report are saved to the saved Report object.
After debugging, it is found that every time the program automatically sends the id of the report object to the ID value of the last inserted, and then the id is + 1 when the database is actually inserted, the reimbursement details object then changes the last foreign key value id to id + 1. what is the solution? Is it the relationship between the primary key generation policy, or do I need to manually add the primary key using assing?