I would like to use 'reference' type of field in my Class Object. I'm not sure how to define it in Java POJO object - I tried setting String,Integer, int, and as well object that are defined in web Dashboard as reference class - I got failure when creating such object (however it is visible correctly in web Dashboard):
Response{resultCode=5, httpResultCode=201, error='Error parsing response. com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected an int but was BEGIN_OBJECT at line 1 column 257 path $.userid', httpReasonPhrase='Created', data=null}
And if I put another object type there, app crashed with Field type Xyz is not supported.
My Class Object:
@SyncanoClass(name = "custom_obj")
public class CustomObj extends SyncanoObject {
public static final String FIELD_TITLEID = "title";
public static final String FIELD_USERID = "userid";
@SyncanoField(name = FIELD_TITLEID)
public String title;
@SyncanoField(name = FIELD_USERID)
public Integer userId;
}
Without setting userId - I get success response.
Yes we know about this bug and is fixed on branch Virtual Table support. In next weekend should be merged to master and published. My answer below relates to this branch.
We decided to drop idea to store reference as Integer
and replace it by SyncanoObject
to allow easy access to object.
For example, if you download CustomObj all inner object (in example YourSyncanoObject
) is collapsed - thats mean you get your object only with id, without all other fields. If you want more information about object you should call syncanoObject.fetch();
But if you want to expanded object we almost finish future similar to Virtual Table with allow you get get your CustomObj with expanded inner syncano object fields.
@SyncanoClass(name = "custom_obj")
public class CustomObj extends SyncanoObject {
public static final String FIELD_TITLEID = "title";
public static final String FIELD_USERID = "userid";
@SyncanoField(name = FIELD_TITLEID)
public String title;
@SyncanoField(name = FIELD_USERID)
public YourSyncanoObject syncanoObject;
}