Update, Insert and delete in one spring boot PUT Request jdbcTemplate

316 Views Asked by At

In a Put Request the JSON file should be checked for all entries and this should be compared with the database. I have a variable that has the last database entry, e.g. the database has two entries, but there are three entries in the JSON file. In this batchUpdate the query creates three entries, but I only want to add the last (the third) entry. How can I do this?

If I use an If( i >= db.size()) the query creates three entries or it says the two entries are missing

I could change the Company company and delete the two entries there, but how do I do that?

   new BatchPreparedStatementSetter() {


                public void setValues(@NonNull PreparedStatement ps, int i) throws SQLException {
                
                        ps.setInt(1, employeeId);
                        ps.setString(2, company.getEmployee().get(i).getFirstName());
                        ps.setString(3, company.getEmployee().get(i).getSurName());
                        ps.setString(4, company.getEmployee().get(i).getPhoneNumber());
                        ps.setString(5, company.getEmployee().get(i).getMobileNumber());
                        ps.setString(6, company.getEmployee().get(i).getFaxNumber());
                        ps.setString(7, company.getEmployee().get(i).getMailAddress());

                }
0

There are 0 best solutions below