String whereClause = "guid = 'SnnadFgSF'";
DataQueryBuilder queryBuilder = DataQueryBuilder.create();
queryBuilder.setWhereClause(whereClause);
Backendless.Data.of(Vehicle.class).find(queryBuilder, new AsyncCallback<List<Vehicle>>() {
@Override
public void handleResponse(List<Vehicle> response) {
String a = response.get(0).getCategory();
Timber.i("Category %s", a);
}
@Override
public void handleFault(BackendlessFault fault) {
Timber.e("Error %s", fault.toString());
}
});
// This code is giving me null value in String a
// But My vehicle table has a guid column with //string value = “SnnadFgSF”
APP ID: F8C6F7F3-E6B2-BCC8-FFF7-2CA63032F900/FBDC30B9-7D28-46AA-BF42-88270EC615FD
Hi @Nkekere_Tommy_Minimann
Do you receive null
value for category
field?
Can you please show your Vehicle
class?
Best Regards,
Maksym
I receive null value for all fields. Below is the Vehicle class
package ng.Payback.Model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Data
@Builder
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
//@Entity
public class Vehicle{
//@Id
//private long id;
//@Unique
//@Index
private String GUID; //Bill Globally Unique Identifier
private String Category;
private String Type;
private String Make;
private String Model;
private int Year;
private String Transmission;
private String Fuel;
private String Colour;
private String Condition;
private String Registration;
private String Problems;
private String Title;
private int Price;
private String Description;
private String Poster;
private String PosterPhone;
private String PosterLocation;
}
What if you try manually adding all the get/set methods for your private fields? Something tells me the annotations you use do not do the required magic. Backendless uses Java reflection to look for Java bean style get/set methods and it appears they are not available which results in the null values.
Regards,
Mark
When Maksym asked to see my Vehicle class I had this suspicion as well (that the annotations might not be generating the getters/setters), so I did it manually, but the problem persists.
Could you please email your Java class file to support@backendless.com and we will give it a try here?
Hi @Nkekere_Tommy_Minimann
The problem is caused by the field name misspelling. The columns in your table start with small letter and fields in your Java class - with capital letter. You should rename your fields in the java class. And it will work even with lombok.
Or if you want to keep the field names with capital letters - you can use Column Name Mapping.
Best Regards,
Maksym
Yes. The problem was caused by my field names starting with capital letters while the columns in my tables started with capital letters. Thanks Maksym.