bidirectional association There is an order form, there is a orderDetails table , physical layout are right, there is no problem . The database used is ms sqlserver, the primary key is used to generate the increment , and orderdetail cascade all. orderdetail entity is a foreign key order_id, and can not be null. Now I create a new order, the primary key id is not set , save the order when prompted me to say sql server error , can not insert null values orderdetail table order_id field , I want to ask this is what happens ?
------ Solution ---------------------------------------- ----
Forum 500 after the second paste ah ~
primary key id is not set than self-energizing Mody ? id not generated out ?
------ Solution ---------------------------------------- ----
when you save or persist , first save the order, and then come back to save orderDetails
------ For reference only --------------- ------------------------
对ah , id I set the increment is not set , and the master of fine I set up the association table is saved when the main table , small tables are also saved , but every time I save the main table, small table inside the main table foreign key is null, and I did not want to save the main table id
------ For reference only ----------------------------------- ----
My jpa annotation settings are saved when the main table table a cascade saves fine
------ For reference only --------- ------------------------------
I also have this problem , detail table foreign key is not maintained be saved.
------ For reference only -------------------------------------- -
I also engaged in this issue , comments configuration cascade saves , but no foreign key
没有评论:
发表评论