6.0 java business logic API jar file breaks code

objectId field is private. There is a getObjectId() method, but no setter. Which do I need to do: Change to public field, or add setObjectId(String) method?

Also, was this an expected breaking change for 6.0?

Either one should do it. I do not quite understand how why it worked before. When the field is private and there is no setObjectId(String) method, the object would not be getting the objectId value assigned since there is no way to assign it.

Neither worked. Here is the POJO. It has the default constructor, it has the private property and the get/set methods. I tested the other way as well with the public property. I can DM you the source code of the whole API service if you’d like

package us.boundlessdesign.customersupport.models;
import weborb.service.MapToProperty;
public class DeviceUsage {
@MapToProperty(property = “objectId”)
private String objectId;
@MapToProperty(property = “deviceid”)
private String DeviceId;
@MapToProperty(property = “mobiledeviceid”)
private String MobileDeviceId;
@MapToProperty(property = “usagecount”)
private Integer UsageCount;
public DeviceUsage() {
}
public String getObjectId() {
return objectId;
}
public void setObjectId(String objectId) {
this.objectId = objectId;
}
public String getDeviceId() {
return DeviceId;
}
public void setDeviceId(String deviceId) {
DeviceId = deviceId;
}
public String getMobileDeviceId() {
return MobileDeviceId;
}
public void setMobileDeviceId(String mobileDeviceId) {
MobileDeviceId = mobileDeviceId;
}
public Integer getUsageCount() {
return UsageCount;
}
public void setUsageCount(Integer usageCount) {
UsageCount = usageCount;
}
@Override
public String toString() {
return “DeviceUsage{” +
“Id='” + objectId + ‘'’ +
“, DeviceId='” + DeviceId + ‘'’ +
“, MobileDeviceId='” + MobileDeviceId + ‘'’ +
“, UsageCount=” + UsageCount +
‘}’;
}
}

What makes you think the object is not saved? It is not clear to me what property is modified after the object is retrieved and what you’re checking. Please elaborate.

Regards,
Mark

The UsageCount property needs to update from 1 to 2. The log shows the record with the objectId = ‘1CA2F9B8-53ED-755F-FF54-E95EB76D8300’ should have the UsageCount value of 1 when it is pulled from the database, then it is incremented to 2, then it should be saved. But after the save, it the returned object still has a UsageCount = 1. Also when looking at it from the Console, it has updated timestamp, but it does not have a changed UsageCount value.

To double check my own sanity, there are other records that have incremented UsageCount values, but not since the 6.0 upgrade.

Could you try (as a test, I need your help in figuring out where it misfires), make the following changes in the DeviceUsage class:

  1. Rename the UsageCount field to:
    private Integer usagecount;
    
  2. Remove the following line:
    @MapToProperty(property = “usagecount”)
    
  3. rename get/set methods:
    public void setusagecount(Integer usageCount) 
    public Integer getusagecount()
    

Please let me know if it gets updated after these changes

Regards,
Mark

Yes, this worked. Does this mean the weborb MapToProperty functionality is not supported anymore? Or possibly there is another change that would allow me to have my property names be different than the DB?

Thanks,

Mark

It should still be supported, but apparently something is not working quite right. This gives us enough information to know where to dig and I am thankful to you for that. I am opening an internal ticket for investigation. We will notify you when it is fixed.

Regards,
Mark

Internal ticket # is BKNDLSS-22105

Thanks much!

Here’s some more information. I turned off all weborb mappings and set the POJO properties to match the DB column names exactly. When I attempt an update, I now see it creating a second record, and it has a higher usagecount value

Here’s the class

And here’s a picture of the records, where is shows identical rows, except usagecount is different.

Hope this adds more light to the weborb mapping issue and a resolution comes soon.

Thanks,
Mark

Make sure to rename objectid to objectId and the methods to getObjectId() and setObjectId( String ).

Regards,
Mark

okay. made the change and it’s working.

To be clear, this appears to mean that weborb mapping doesn’t work at all and i have to make all properties, and all getters and setters in all classes match the database columns for spelling and casement exactly. Is that correct?

If this behavior is accidental, and you are working on a fix, do you have an eta? I ask because I want to plan my application release accordingly.

If this behavior is purposeful, I will go ahead and refactor all my server code immediately and move through testing and on to other tasks.

I mostly don’t want to change code temporarily and then change it back to use weborb mapping.

Thanks,

Mark

Yes, it is a problem, I confirmed it here. I do not have an eta yet, but an engineer has already been assigned to the issue and is making progress.

Just to confirm, does the problem happen in both debug and production modes of business logic?

Regards,
Mark

i have been avoiding publishing the changes to production, so I can’t confirm. I was going to rip/replace weborb and get it through testing and into production quickly if that matches with your fix estimate.

I’ll keep an eye on this thread and decide how long to wait.

I appreciate the help.

Mark

Hi @Mark_Moline !

Could you please create project with code to reproduce this problem using “bin” and “libs” directories from actual project in which problem occurs?
After doing so pack it to arhive and send it here.
We believe that problem can be caused by binaries version mismatch and such “test” project will help us.

Regards, Andriy

Hi @Mark_Moline!

If you want to have property names different from DB column names you should use MapToProperty annotation on getter/setter and make fields private. If fields in your data model class is public then you can use this annotation directly on your fields.
We will update our documetation to describe this moment. Sorry for inconvenience.

Regards, Andriy

Hi @Mark_Moline,

To clarify what @Andriy_Konoz wrote, I’d like to share some background information. What happened prior to the 6.0 release the @MapToProperty annotation wasn’t used because it is applied to private fields. What made it work is the backend ignored the capitalization of the column names. That is if you created a column in console named mobiledeviceid and in your Java code the property was named MobileDeviceId, the SDK would serialize the property exactly as it is written, and the backend would still locate the right column because it ignored the upper case. With the 6.0 release, the check was made to be stricter which showcased the problem you’re experiencing. There are three approaches to fixing it:

  1. Do not use the annotation and change the property names to match what they are in the database schema
  2. Make the fields public and use the annotation with the fields.
  3. Apply the @MapToProperty annotation to the getXXX() methods.

Please let me know if you have any questions.

Regards,
Mark

Okay. thank you for the information. I had been pulled onto something else for the last few days. For the time being, I’ve used option 1.

I appreciate this!

Hello @Mark_Moline

We’ve released the new version of Backendless.
Please, could you confirm that this issue doesn’t appear?

Regards,
Inna