I’m developing Web Service that has access to database via JDBC. I’m using DAO pattern. I’ve implemented all necessary methods: findAll, add, update, delete. But I got confused with update method. It has Object as input parameter. But how does he know which field needs to be updated. For example, I need to update field ‘name’ I use query 'update table set name='smth where id=2' but if I need to update ‘surname’?? what is the best practice to tell update method what actually to update?
thank you
I’m developing Web Service that has access to database via JDBC. I’m using DAO
Share
You’ll need to change your method signature to include a Map of column names and values.
Have a look at the Spring JDBC template for a nice example of how to design and implement such a thing.