weird case of data getting duplicated

Hi ,

i been having some issues when i save the data. here is my scenario:

3 data object
phonebook , contact , contact_number

relationship:
phonebook can have multiple contact
contact can have multiple contact_number

Scenario

  1. i have an existing contact with 2 contact number(contact number A and B) . it is successfully created and store in database. but this contact is not added to phonebook.
  2. under certain situation , i want to add this contact to phonebook. When i add this contact to the phonebook. it successfully add , but the contact number gets duplicated. so i have 4 contact number linked to contact.

i’m confused here . any thoughts?

using Backendless.Persistence.save( xxx , new AsyncCallback<xxx>() ) to save. with java custom object

sorry correction

scenario

  1. i have an existing contact with 2 contact number(contact number A and B) . it is successfully created and store in database. but this contact is not added to phonebook.
  2. under certain situation , i want to create a new phonebook object with link to the existing contact. after add this new object , the contact number object becomes 4 with duplicate of each contact number.

Hi Laurent,

where/how do you get contact object to save it in phonebook? Do you previously get it from server or use same object you created before?

The point is that the objects can be duplicated only if the saved object (no matter how similar to the existing it is) no field objectId, the server perceive it as a new object and thus “duplicates” (in fact - will really create new, with the same fields, except the objectId).
To avoid this, you must firstly obtain an object from a server (contact), and then add it to a phonebook.

the contact object is retrieve from server with valid object id.

only the phonebook object is new and not created before.

the workaround i made now is

  1. create a new phonebook object first
  2. then assign the contact object.

this seems like double work and call.

Could you please provide us code sample how you’re doing it? I’ve reproduced same table schema and scenario, but can’t reproduce issue. This would help us to find the problem.