0

I am using SQL objects API to work with the data in my database and have run into an annoying issue :

When users are using my front end, they can type in values etc and pick from dropdowns etc before clicking apply to save all the changes to the database, the problem there is that I never really know WHICH columns are going to be changed within the table on each write.

The code to do an update to a table (according to the internet) is as follows :

    @SqlUpdate("UPDATE users SET col1=val1, col2=val2 WHERE Id= :Id")
void updateStream(@BindBean User user);

but since I never know which fields will be updated, I can't include the column names, surely?

Help greatly appreciated, thanks.

Slippy
  • 1,253
  • 5
  • 22
  • 43

1 Answers1

0

AFAIK jdbi is not that flexible. It has @Define feature but I don't think it solves your problem since the amount of parameters may vary.

The common approach is to update all the fields there is. Since the client sends the whole User object to you including the unchanged fields, it will only affect relevant columns.

Community
  • 1
  • 1
Natan
  • 2,816
  • 20
  • 37