亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

java - mybatis多表關聯(lián)新增數(shù)據(jù)
ringa_lee
ringa_lee 2017-04-18 10:43:43
0
4
636
ringa_lee
ringa_lee

ringa_lee

reply all(4)
黃舟

SQL should reduce business logic as much as possible. The verification of some business logic can be done in the business layer. SQL can be as simple as Insert

伊謝爾倫

For multiple tables, I have the same idea as the person above. After an insert statement is executed, return its primary key and insert it into another table containing a foreign key. For example


Then get the returned primary key in your business logic and insert it into another table. This avoids complex SQL

左手右手慢動作

Slowly write multiple insert statements in the business layer, and it is not troublesome to enable the return of primary keys and correlation. Anyway, they are all generated mappers now.

You don’t have to worry about data integrity, there’s nothing to be afraid of if you control your affairs well.

阿神

I have solved the problem. There is no need for the <selectKey> tag in mysql. Just add the two attributes useGeneratedKeys="true" keyProperty="id". After inserting data, the primary key value will be automatically returned to the object. . Then just store the primary key value in the association table, thus establishing an association.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template