Realm Blog

Realm Java 0.77

We just pushed a Realm Java update to this website and to JCenter. In this release we introduce a lovely new feature that many of you have been asking for and we addressed several improvements and fixes.

Standalone Objects

It is now possible to instantiate standalone instances of your model classes. This means you can now create objects that are not backed by Realm and only living in memory, and add them to a Realm at a later time. This comes in handy for user input and to work with other libraries, such as GSON or Retrofit. It is also of course possible to add your standalone objects instances to a Realm at any point in a very easy way.

User user = new User("John");
user.setEmail("[email protected]");

// Copy the object to Realm. Any further changes must happen on realmUser
User realmUser = realm.copyToRealm(user);

Check out our docs for more info.

Transaction Blocks

Instead of manually keeping track of realm.beginTransaction(), realm.commitTransaction(), and realm.cancelTransaction() you can use the `realm.executeTransaction() method, which will automatically handle begin/commit, and cancel if an error happens.

realm.executeTransaction(new Realm.Transaction() {
    public void execute(Realm realm) {
        User user = realm.createObject(User.class);
        user.setEmail("[email protected]");

Multi-Field Sorting

It is now possible to sort your query results by more than one field. Check out our Javadocs for allObjectsSorted() & findAllSorted().

We took the occasion to improve the naming of the methods returning sorted results. The old ones are still available but deprecated and they will be removed in the next major release.

Breaking Changes

  • As promised we removed the Realm static constructors using the auto-refresh argument. Auto-refresh is now handled automatically by Realm.
  • Our experimental encryption feature is temporarily unavailable as we wrap up a complete rewrite. We expect to ship a new version with encryption enabled in a few days.


In no particular order:

  • RealmResults.sort() now has better error reporting.
  • Added more logging capabilities at the JNI level.
  • Fixed bug when doing queries on the elements of a RealmList, i.e., like Realm.where(Foo.class).getBars().where().equalTo(“name”).
  • Throw NoSuchMethodError when RealmResults.indexOf() is called, since it’s not implemented yet.
  • Added more precise imports in proxy classes to avoid ambiguous references.
  • Improved handling of empty model classes in the annotation processor
  • Fixed bug causing refresh() to be called on background threads with closed Realms.
  • Fixed bug where calling Realm.close() too many times could result in Realm not getting closed at all. This now triggers a log warning.
  • RealmList.remove() now properly returns the removed object.
  • Calling realm.close() no longer prevents updates to other open realm instances on the same thread.

Thank you

We really could not make this without you. Keep the feedback coming! It’s our most valuable resource to make Realm better with every release. As always, we’re around on the mailing list, Stack Overflow, GitHub, and Twitter.

Realm Team

At Realm, our mission is to help developers build better apps faster. We provide a unique set of tools and platform technologies designed to make it easy for developers to build apps with sophisticated, powerful features — things like realtime collaboration, augmented reality, live data synchronization, offline experiences, messaging, and more.

Everything we build is developed with an eye toward enabling developers for what we believe the mobile internet evolves into — an open network of billions of users and trillions of devices, and realtime interactivity across them all.

Get more development news like this