Data handler afterFind not returning correct result

I do a REST API find() call to get a record from a table called Subscriptions. The row is correctly returned as the first object in the collection.
However if I implement:



@Override
public void afterFind( RunnerContext context, BackendlessDataQuery query, ExecutionResult<BackendlessCollection<Subscriptions>> result ) throws Exception
{
super.afterFind(context, query, result);
return;

Then the first object in the collection no longer just contains default values (ie. all its members are not set to what they actually are in the table for that corresponding row).

Hi Simon,

Does the problem show up both in Debug and Production modes?

Regards,
Mark

Yes, sorry I intended to mention that!

Thanks, Simon. We will be investigating it.

Regards,
Mark

Hi Simon,

We need more information for investigate the issue.
Could you please provide project’s source code or more information?

With kind regards,
Eugene

I tried adding the following two lines but it didn’t solve the issue.

private String ___class;
private String __meta;

and also setters and the getters.

Hi,
Is there any update on this issue?
Regards,
Simon

Hi, Simon,

Seems like you added some properties on your console for Subscriptions table, but didn’t regenerate the corresponding model. So your models.Subscriptions class did not contain the new fields and that’s why they were ignored when received from the server.

I still have the problem. I re-exported all the table Java classes (models) and Bootstrap.java content from the console to make sure all the table columns and corresponding Java object setter/getter methods were matching.
Have you been able to successfully test the use of afterFind()? If so could I have please the same test code and table schema export to try it myself?

I was using the code you provided at http://support.backendless.com/t/private-msg-to-eugene and my local CodeRunner in debug mode. When I added one of the missing fields to Subscriptions class, I began to receive it in response to REST find request. That’s because you get your response after the afterFind() handler, and in this handler you receive an object, which corresponds to your model (class).

I need some clarifications to your problem now. Are you getting response with some properties missing or with wrong values, but all properties? In general, what is the expected result and what is the actual result?

Thanks in advance.

Hi Sergey,

I investigated the problem a little more. The issue I found is:

  1. With no afterFind() implemented in the Subscription table event handler I get the objects (table records) and the “Type” column is populated correctly.

  2. With the following afterFind() implemented in the Subscription table event handler I get the same objects (I compared the Objected IDs) but the “Type” column (field) is not populated.

Originally because my client code was only printing out the value of the Type field from the response and I observed no value when using afterFind() I mistakenly thought the response contained no objects in the collection, what is really happening is the behaviour I explained above in 1) and 2).

@Override
public void afterFind( RunnerContext context, BackendlessDataQuery query, ExecutionResult<BackendlessCollection<Subscriptions>> result ) throws Exception {
super.afterFind(context, query, result);
}

I checked it again with CodeRunner in debug mode and the project mentioned above. The field “Type” is returned in response with the value, and also it is already populated inside of afterFind() handler.

Could you please debug your code in afterFind() method and check whether the field is populated when the result is returned from server?

Also checked with Data Service’s REST Console on your application, also got proper results.