realm / realm-java

Realm is a mobile database: a replacement for SQLite & ORMs
http://realm.io
Apache License 2.0
11.47k stars 1.75k forks source link

Realmlist<String> not able to extract it back #5536

Closed ayushishah-easternts closed 7 years ago

ayushishah-easternts commented 7 years ago

Hi,

I am using realm 4.1.1

When trying to use Realmlist in RealmObject we aren't able to retrieve it back

RealmObject data members are as below:

   @PrimaryKey
    private String product_id;
    private String product_name;
    private String specifications_sheet;
    private String brochure;
    private String product_warranty;
    private String product_description;
    private String model;
    private String sku;
    private String upc;
    private String quantity;
    private String image;
    private String manufacturer_id;
    private String manufacturer;
    private String retail_price;
    private String gold_price;
    private String trade_price;
    private String price_currency;
    private String trade_only;
    private String products_type;
    private String category_id;
    private String category_name;
    private String subcategory_id;
    private String subcategory_name;
    private RealmList<String> images = new RealmList<>();`

Here when I am trying to do productDatas.getImages().size() the size is always coming zero

Please let me know where am I going wrong

cmelchior commented 7 years ago

Hard to say without more information.

ayushishah-easternts commented 7 years ago
LogClass.e("JSON", jObjProduct.toString()); realm.createOrUpdateObjectFromJson(ProductData.class, jObjProduct);

ProductData productDatas = realm.where(ProductData.class)
                                                            .equalTo(ProductData.Cols.PRODUCT_ID, productId)
                                                            .findFirst();

Using above piece of code to insert data in realm. In which array size is greater than 1

@cmelchior : The json would be coming from server side , hence confirming the array size should be greater than zero

cmelchior commented 7 years ago

Arrays of Primitives are not supported yet by our JSON methods as mentioned in the changelog: https://github.com/realm/realm-java/blob/master/CHANGELOG.md#400-2017-10-16

It is being added in this PR though https://github.com/realm/realm-java/pull/5505, so should be in the next minor release.

ayushishah-easternts commented 7 years ago

@cmelchior Thanks for the prompt response . By when can we expect the minor release ? Should we use workaround as we used for earlier realm version or wait for the release ?

cmelchior commented 7 years ago

Hopefully, we can release next week, but it might change. So that will depend on your timeline. Alternative you can clone that branch and build a version of Realm yourself to include.

beeender commented 7 years ago

this will be released as part of 4.2.0. See #5536