You are adding a new client twice, at the start of your code and then again within another if else statement.
I am not familiar with the code used ?-Java/MongoDb -? but the basics is the same
How it works -
1. Search data table for client with ID 1.
2. If client exist, check if new data corresponds with table data,
3. If it does not compare, update the record with the new data,
4. If the client does not exist, add a new record to data table.
while(result.next()) {
if(dbData == null || dbData.isEmpty()) {
Customer customer = new Customer();
} else {
UPDATE RECORD HERE...
}
You then have to run a new query again if you want to see the updated or the new record.