How to crate a one-to-one relationship and add respective data in Backendless Android?

I’m have a 1:1 mapping from table Users->UserAddress. [each user is associated with single address]

I have create table “Address” with fields [landmark, pincode, contact_no].

I have set one-to-mapping on table “Users” by creating a column “address” and set Data Relation (1:1): Address
I’m not setting address at the time of registration. I want it once user checkout from app. If I try to set the “address” property then it gives an exception " No property address".

BackendlessUser user = new BackendlessUser();
        user.setProperty("name", name);
        user.setProperty("email", email);

//        UserAddress userAddress = new UserAddress();
//        userAddress.setLandmark("empty");
//        userAddress.setPincode("empty");
//        userAddress.setContact_no("empty");
//        user.setProperty("address", userAddress);

        Backendless.UserService.register(user, new AsyncCallback<BackendlessUser>() {
            public void handleResponse(BackendlessUser registeredUser) {

                // Registration successful!

            public void handleFault(BackendlessFault fault) {
                // fault.getMessage());

Now on checkout page I’m creating UserAddress object and updating Backendless User as below

UserAddress userAddress = new UserAddress();

        BackendlessUser user = Backendless.UserService.CurrentUser();
        user.setProperty("address", userAddress);
        Backendless.UserService.update(user, new AsyncCallback<BackendlessUser>() {
            public void handleResponse(BackendlessUser backendlessUser) {
                // user updated successfully

            public void handleFault(BackendlessFault fault) {
                // fault.getMessage());

It gives below exception -
Cannot update object wihtpout any properties: address

I’m referring below doc -

I want User to have a single Address while needs to be filled at the time of checkout.


Show please UserAddress class. Looks like the problem is there.
best regards,

Hello Alexandr.

String landmark, pincode, contact_no; 

 public void setContact_no(String contact_no) { 
 this.contact_no = contact_no; 
 public void setLandmark(String landmark) { 
 this.landmark = landmark; 
 public void setPincode(String pincode) { 
 this.pincode = pincode; 

above is UserAddress.class

Getters and public no-argument constructor are missing in the class, it causes the problem you face with.

ok let me check

Thanks a lot @Alexandr Navara :slight_smile: