Backendless Support
 
Cannot Reproduce

Remove related data one to one relationship Backndless 3.0

I have a table Advertisement and User

There is one to one relation, I can create advert without User

But if I create advert with user and want to remove User, I can't do it.

1)I load advert

2)I'm trying to do Advertisement.setUser(null)

3)save advert

but nothing change in database.

Leave a Comment

Comments (13)

photo
1

Hi,

how do you load advert object? The reason for this behavior may be that the advert object is not loaded with its relations (User for this case). Set relationsDepth to 1 or specify which dependencies should return with object, then `setUser` should work.

Regards,

Stanislaww

photo
1

I load advert and all relations with autoload

When I write

Advert.setUser (null)

Nothing changes in my database

photo
1

After I save advert in response advert is without user

So, user ==null

But in database nothing was changed

photo
1

Could you please provide us your App ID so that we can investigate this problem?

photo
1

88E2CF0E-7753-F3A5-FF0C-CA45A1D0C500

photo
1

I tesded app again and I notised, that I can't remove any relations

one to one

one to many

but it worked

photo
1

I just tried to do the same thing and everything worked fine.

Am I correctly understand that after removing the `owner` field of the Advertise object and then saving this object, you still see the link in the column "owner" to the user (do not confuse it with the `ownerId` column)? If I misunderstood, please specify again what exactly you are doing (simple example of code snippet) and what you are seeing in result.

photo
1

I just tried to remove Comment, Region

nothing work

photo
1

To help you I need to know how exactly you do it to reproduce this problem.

photo
1

  1. Backendless.Data.of(Advertisement.class).findById(advertisement.getObjectId(), new AsyncCallback<Advertisement>() {

    @Override

    public void handleResponse(Advertisement response) {

    response.setBreed(null);

    response.setOwner(null);

    response.getComments().remove(0);

    sendEditPost(response, uploadListener);

    }

    private void sendEditPost(final Advertisement advertisement, final UploadListener uploadListener) {

    Backendless.Data.of(Advertisement.class).save(advertisement, new AsyncCallback<Advertisement>() {

    @Override

    public void handleResponse(Advertisement response) {

    Log.d(TAG, "sendEditPost handleResponse: " + response);

In Log I see edited advert, owner ==null, breed ==null

but in database nothing changed

photo
1

I don't know what happened, but it started to work

I didn't change any row of code

Sorry I disturb you

Thanks a lot

photo
1

No problem. Let us know if you'll have any problems with this again.

photo
photo
1

Thank you, we'll investigate this problem as soon as possible and let you know in this thread about the result.

You may reference to this issue by it's internal id - BKNDLSS-15189.

Regards,

Stanislaw