{"action":"closed","issue":{"url":"https://api.github.com/repos/realm/realm-java/issues/5483","repository_url":"https://api.github.com/repos/realm/realm-java","labels_url":"https://api.github.com/repos/realm/realm-java/issues/5483/labels{/name}","comments_url":"https://api.github.com/repos/realm/realm-java/issues/5483/comments","events_url":"https://api.github.com/repos/realm/realm-java/issues/5483/events","html_url":"https://github.com/realm/realm-java/issues/5483","id":269184462,"number":5483,"title":"Replace exist field from json that not content this field?","user":{"login":"lmdic","id":303539,"avatar_url":"https://avatars3.githubusercontent.com/u/303539?v=4","gravatar_id":"","url":"https://api.github.com/users/lmdic","html_url":"https://github.com/lmdic","followers_url":"https://api.github.com/users/lmdic/followers","following_url":"https://api.github.com/users/lmdic/following{/other_user}","gists_url":"https://api.github.com/users/lmdic/gists{/gist_id}","starred_url":"https://api.github.com/users/lmdic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lmdic/subscriptions","organizations_url":"https://api.github.com/users/lmdic/orgs","repos_url":"https://api.github.com/users/lmdic/repos","events_url":"https://api.github.com/users/lmdic/events{/privacy}","received_events_url":"https://api.github.com/users/lmdic/received_events","type":"User","site_admin":false},"labels":[{"id":320042815,"url":"https://api.github.com/repos/realm/realm-java/labels/T:Duplicate","name":"T:Duplicate","color":"d4c5f9","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2017-10-27T17:44:55Z","updated_at":"2017-10-30T04:27:50Z","closed_at":"2017-10-30T04:27:50Z","author_association":"NONE","body":"POJO:\r\n\r\n```\r\npublic class Offer extends RealmObject {\r\n    @PrimaryKey\r\n    private int id;\r\n    private String name;\r\n    private boolean downloaded;\r\n}\r\n```\r\n\r\nI update field \"**download**\" by **true** like this (click special button in my app):\r\n\r\n```\r\npublic static void update(final int offerId, final boolean downloaded) {\r\n        Realm realm = Realm.getDefaultInstance();\r\n        try {\r\n            realm.executeTransaction(new Realm.Transaction() {\r\n                @Override\r\n                public void execute(Realm realm) {\r\n                    Offer offer = realm.where(Offer.class).equalTo(Offer.ID, offerId).findFirst();\r\n                    offer.setDownloaded(downloaded);\r\n                }\r\n            });\r\n        } finally {\r\n            realm.close();\r\n        }\r\n    }\r\n\r\n```\r\n\r\nOK. It's work. Now field  **download = true**.\r\nAnd I need this field not change any more!\r\n\r\nBut then incoming json like this (in this json no field \"download\")\r\n\r\n```\r\n[\r\n  {\r\n    \"id\": 1,\r\n    \"name\": \"my name\"\r\n  },\r\n  {\r\n    \"id\": 2,\r\n    \"name\": \"my name2\"\r\n  }\r\n  ]\r\n```\r\n\r\n\r\n\r\nI update Offer like this :\r\n\r\n    public static void updateOffers(final List<Offer> offersList) {\r\n        Realm realm = Realm.getDefaultInstance();\r\n        try {\r\n            realm.executeTransaction(new Realm.Transaction() {\r\n                @Override\r\n                public void execute(Realm realm) {\r\n                    RealmList<Offer> offersRealmList = new RealmList<>();\r\n                    offersRealmList.addAll(offersList);\r\n                    realm.copyToRealmOrUpdate(offersRealmList);\r\n                }\r\n            });\r\n        } finally {\r\n            realm.close();\r\n        }\r\n    }\r\n\r\n\r\n\r\n\r\n\r\n\r\nAnd after this update all fields \"**download**\" again = **FALSE**!!!\r\n\r\nQuestions:\r\n1.This is a normal of Realm to replace exist field? (In json no this field)\r\n2.How avoid to replace filed \"**download**\"?\r\n\r\n"}}
{"actor":{"display_login":"beeender"}}