{"action":"created","issue":{"url":"https://api.github.com/repos/js-data/js-data/issues/206","labels_url":"https://api.github.com/repos/js-data/js-data/issues/206/labels{/name}","comments_url":"https://api.github.com/repos/js-data/js-data/issues/206/comments","events_url":"https://api.github.com/repos/js-data/js-data/issues/206/events","html_url":"https://github.com/js-data/js-data/issues/206","id":103490629,"number":206,"title":"Resource instance get 'undefined' if belongsTo-relation cannot be resolved","user":{"login":"t-richter","id":11031194,"avatar_url":"https://avatars.githubusercontent.com/u/11031194?v=3","gravatar_id":"","url":"https://api.github.com/users/t-richter","html_url":"https://github.com/t-richter","followers_url":"https://api.github.com/users/t-richter/followers","following_url":"https://api.github.com/users/t-richter/following{/other_user}","gists_url":"https://api.github.com/users/t-richter/gists{/gist_id}","starred_url":"https://api.github.com/users/t-richter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/t-richter/subscriptions","organizations_url":"https://api.github.com/users/t-richter/orgs","repos_url":"https://api.github.com/users/t-richter/repos","events_url":"https://api.github.com/users/t-richter/events{/privacy}","received_events_url":"https://api.github.com/users/t-richter/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/js-data/js-data/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/js-data/js-data/labels/needs%20more%20info","name":"needs more info","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-08-27T11:46:10Z","updated_at":"2016-01-06T08:26:52Z","closed_at":null,"body":"I'm running into an issue when loading certain entities are loaded from my restful backend, in this case grails.\r\nIn Grails it is not necessary to define a relation on both sides.\r\ne.g. I have an entity \"Entity\" , which belongsTo \"Statustype\" , but Statustype does not define a \"hasMany: measure\", which is o.k. with grails (and unfortunately can't be changed in this case, as I don't have access to the server side)\r\n\r\nWhen trying to load such an entity into the DS, get a result-array with the correct length, but most of the entries are \"undefined\".\r\nThe error message I get is:\r\n\r\n```javascript\r\nTypeError: Cannot read property 'id' of null\r\n    at get (http://localhost:63342/www/bower_components/js-data/dist/js-data.js:2890:20)\r\n    at Entity.exports.default.applyRelationGettersToTarget.forEach.prop.set (http://localhost:63342/www/bower_components/js-data/dist/js-data.js:1193:34)\r\n    at Entity.copyProp (http://localhost:63342/www/bower_components/js-data/dist/js-data.js:2817:24)\r\n    at http://localhost:63342/www/bower_components/js-data/dist/js-data.js:2776:28\r\n    at exec (http://localhost:63342/www/bower_components/js-data/dist/js-data.js:3082:20)\r\n    at forIn (http://localhost:63342/www/bower_components/js-data/dist/js-data.js:3049:18)\r\n    at forOwn (http://localhost:63342/www/bower_components/js-data/dist/js-data.js:2774:10)\r\n    at Object.deepMixIn (http://localhost:63342/www/bower_components/js-data/dist/js-data.js:2805:18)\r\n    at http://localhost:63342/www/bower_components/js-data/dist/js-data.js:4011:34\r\n    at DS._inject (http://localhost:63342/www/bower_components/js-data/dist/js-data.js:4056:12) Object\r\n  defaultsPrototype.error\t\r\n```\r\nDebugging shows that in line 1192 the function\r\n```javascript\r\nprop.set = function (parent) {...}\r\n```\r\nis in this cases called with parent==null and later in the result-set the instance is replaced by \"undefined\".\r\n\r\nBTW: Is it in any case necessary to define a relation on both sides with js-data.? The docs are a bit unclear about this point.\r\n\r\nThanks for your input :-)\r\n"},"comment":{"url":"https://api.github.com/repos/js-data/js-data/issues/comments/169265370","html_url":"https://github.com/js-data/js-data/issues/206#issuecomment-169265370","issue_url":"https://api.github.com/repos/js-data/js-data/issues/206","id":169265370,"user":{"login":"jmdobry","id":1213510,"avatar_url":"https://avatars.githubusercontent.com/u/1213510?v=3","gravatar_id":"","url":"https://api.github.com/users/jmdobry","html_url":"https://github.com/jmdobry","followers_url":"https://api.github.com/users/jmdobry/followers","following_url":"https://api.github.com/users/jmdobry/following{/other_user}","gists_url":"https://api.github.com/users/jmdobry/gists{/gist_id}","starred_url":"https://api.github.com/users/jmdobry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmdobry/subscriptions","organizations_url":"https://api.github.com/users/jmdobry/orgs","repos_url":"https://api.github.com/users/jmdobry/repos","events_url":"https://api.github.com/users/jmdobry/events{/privacy}","received_events_url":"https://api.github.com/users/jmdobry/received_events","type":"User","site_admin":false},"created_at":"2016-01-06T08:26:52Z","updated_at":"2016-01-06T08:26:52Z","body":"> In Grails it is not necessary to define a relation on both sides.\r\n\r\nThat's okay, but JSData still needs the relationship defined both ways."}}