Home > front end >  Is not the case in SQL, the when how to realize dynamic update?
Is not the case in SQL, the when how to realize dynamic update?

Time:09-19

I a small white, met a confused, directly on the problem,

The existing three tables: a, b, c

A table fields: id, customer accounts, znum
B table fields: id, groupname
C table fields: id, customid, znum

Table relationships: a table of customer account corresponding table b groupname, b table id of the corresponding c table customid


Requirements: znum fields in a table on table relationship of one-to-one znum updates to table c,

Now I'm confused, value and conditions of each update is different, I how to realize dynamic update, because you want to import data from hundreds, write so many case, when reality, certainly not
How to through SQL to solve this problem? (can't) after the end of the code, I hope someone to help, very grateful!

CodePudding user response:

The persistence framework is superior, the editor of an entity attributes, only need to put all can edit the properties of the reset switch, JPA will compare what property value has changed, and the change of the properties of an update, no change don't update it. If you haven't change do not perform the update the


It is completely black box callers, caller you just need to call the merge method, I cut a mybaties generated SQL statements (asked me to write a... , do not think about)!

CodePudding user response:



Entirely from real projects, is too long, I can only put them together

CodePudding user response:

If you mean each update a table, automatic update table c, you can consider using database triggers, check the details
  • Related