Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Realm 5.8.0: findAllSorted - compile error

Tags:

android

realm

Android Studio 3.2. Realm: 4.1.0

In my build.gradle:

buildscript {  
    ext.REALM_VERSION = '4.1.0'

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'

        classpath "io.realm:realm-gradle-plugin:$REALM_VERSION"      
    }
}

In my app/build.gradle:

implementation 'io.realm:android-adapters:2.0.0'

Here snippet:

RealmQuery<Merchant> realmQuery = realm.where(Merchant.class);
return realmQuery.findAllSorted(sortByFieldName, Sort.ASCENDING);

And this code success work. Nice.

But when I upgrade Realm to 5.8.0 I get compile error:

Error:
error: cannot find symbol
                return realmQuery.findAllSorted(sortByFieldName, Sort.ASCENDING);
like image 797
Alexei Avatar asked Dec 17 '22 19:12

Alexei


1 Answers

realmQuery.findAllSorted(sortByFieldName, Sort.ASCENDING)

Is replaced by

realmQuery.sort(sortByFieldName, Sort.ASCENDING).findAll()

since 5.0.0


See change log:

5.0.0 (2018-03-15)

Breaking Changes

  • The OrderedCollectionChangeSet parameter in OrderedRealmCollectionChangeListener.onChange() is no longer nullable. Use changeSet.getState() instead (#5619).

  • realm.subscribeForObjects() have been removed. Use RealmQuery.findAllAsync(String subscriptionName) and RealmQuery.findAllAsync() instead.

  • Removed previously deprecated RealmQuery.findAllSorted(), RealmQuery.findAllSortedAsync(), RealmResults.distinct() and RealmQuery.distinctAsync(). Use RealmQuery.sort() and RealmQuery.distinct() instead.

Please note that this change also demands updating to realm-android-adapters 3.0.0.

like image 97
EpicPandaForce Avatar answered Dec 29 '22 10:12

EpicPandaForce