{"action":"created","issue":{"url":"https://api.github.com/repos/Stuart-campbell/RushOrm/issues/78","labels_url":"https://api.github.com/repos/Stuart-campbell/RushOrm/issues/78/labels{/name}","comments_url":"https://api.github.com/repos/Stuart-campbell/RushOrm/issues/78/comments","events_url":"https://api.github.com/repos/Stuart-campbell/RushOrm/issues/78/events","html_url":"https://github.com/Stuart-campbell/RushOrm/issues/78","id":110057449,"number":78,"title":"getId() returns NULL, resulting in not being able to delete objects?","user":{"login":"olavbg","id":5698558,"avatar_url":"https://avatars.githubusercontent.com/u/5698558?v=3","gravatar_id":"","url":"https://api.github.com/users/olavbg","html_url":"https://github.com/olavbg","followers_url":"https://api.github.com/users/olavbg/followers","following_url":"https://api.github.com/users/olavbg/following{/other_user}","gists_url":"https://api.github.com/users/olavbg/gists{/gist_id}","starred_url":"https://api.github.com/users/olavbg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olavbg/subscriptions","organizations_url":"https://api.github.com/users/olavbg/orgs","repos_url":"https://api.github.com/users/olavbg/repos","events_url":"https://api.github.com/users/olavbg/events{/privacy}","received_events_url":"https://api.github.com/users/olavbg/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-06T17:23:48Z","updated_at":"2015-10-13T08:17:47Z","closed_at":null,"body":"I have a java class Movie:\r\n```java\r\npublic class Movie extends RushObject {\r\n\r\nprivate String tittel = \"\";\r\nprivate String format = \"\";\r\n\r\npublic Movie() {\r\n}\r\n\r\npublic Movie(String tittel, String format){\r\n    this.tittel = tittel;\r\n    this.format = format;\r\n}\r\n//...\r\n//getters, setters, equal & hashcode\r\n//...\r\n\r\n}\r\n```\r\n\r\nI create a new Movie:\r\n```java\r\nMovie movie = new Movie(\"Thor\",\"Blu-Ray\");\r\n```\r\n\r\nAnd saves it: \r\n```java\r\nmovie.save(new RushCallback() {\r\n   @Override\r\n    public void complete() {\r\n        Log.d(\"movie.save()\",\"\"+movie.getId());\r\n        Snackbar.make(v, movie.getTittel() + \" added.\", Snackbar.LENGTH_LONG).show();\r\n    }\r\n});\r\n```\r\n\r\nHere movie.getId() returns a valid id.\r\n\r\nBut.. When I at startup of application runs this:\r\n```java\r\nfor (Movie movie : new RushSearch().orderAsc(\"tittel\").find(Movie.class)) {\r\n     Log.d(\"Found movie in DB\", movie.getTittel());\r\n     Log.d(\"Found movie in DB\", \"\" + movie.getId());\r\n}\r\n```\r\nmovie.getId() is NULL:\r\n```\r\n10-06 19:16:42.815 25729-25729/com.olavbg.android.filmbase D/Found movie in DB: Thor\r\n10-06 19:16:42.815 25729-25729/com.olavbg.android.filmbase D/Found movie in DB: null\r\n```\r\n\r\nWhen trying to delete this movie the callback gets called, but I see no log entry from RushOrm. Also, on the next startup the movie is still there. RushCore.deleteAll(Movie.class) and RushCore.clearDatabase() works as expected.\r\n\r\nI searched and found this issue: https://github.com/Stuart-campbell/RushOrm/issues/14\r\nSo I tried overriding getId() in Movie.java:\r\n```java\r\n@Override\r\npublic String getId() { return RushCore.getInstance().getId(this); }\r\n```\r\nI have also tried this:\r\n```java\r\nmovie.save(new RushCallback() {\r\n   @Override\r\n    public void complete() {\r\n        Log.d(\"movie.save()\",\"\"+movie.getId());\r\n        movie.setTempId(movie.getId());\r\n        Snackbar.make(v, movie.getTittel() + \" added.\", Snackbar.LENGTH_LONG).show();\r\n    }\r\n});\r\n```\r\nAnd then when deleting:\r\n```java\r\nRushCore.getInstance().registerObjectWithId(movie, movie.getTempId());\r\nmovie.delete();\r\n```\r\nBut still no luck.\r\nAm I doing something wrong? "},"comment":{"url":"https://api.github.com/repos/Stuart-campbell/RushOrm/issues/comments/147642765","html_url":"https://github.com/Stuart-campbell/RushOrm/issues/78#issuecomment-147642765","issue_url":"https://api.github.com/repos/Stuart-campbell/RushOrm/issues/78","id":147642765,"user":{"login":"Stuart-campbell","id":3994391,"avatar_url":"https://avatars.githubusercontent.com/u/3994391?v=3","gravatar_id":"","url":"https://api.github.com/users/Stuart-campbell","html_url":"https://github.com/Stuart-campbell","followers_url":"https://api.github.com/users/Stuart-campbell/followers","following_url":"https://api.github.com/users/Stuart-campbell/following{/other_user}","gists_url":"https://api.github.com/users/Stuart-campbell/gists{/gist_id}","starred_url":"https://api.github.com/users/Stuart-campbell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Stuart-campbell/subscriptions","organizations_url":"https://api.github.com/users/Stuart-campbell/orgs","repos_url":"https://api.github.com/users/Stuart-campbell/repos","events_url":"https://api.github.com/users/Stuart-campbell/events{/privacy}","received_events_url":"https://api.github.com/users/Stuart-campbell/received_events","type":"User","site_admin":false},"created_at":"2015-10-13T08:17:47Z","updated_at":"2015-10-13T08:17:47Z","body":"Hi,\r\n\r\nJust had a quick look.\r\n\r\nI think the issue is at this line https://github.com/Stuart-campbell/RushCore/blob/master/src/main/java/co/uk/rushorm/core/RushCore.java#L158\r\n\r\nAll the ids are stored in a Map this is so a base object is not required and you can use an interface instead.\r\n\r\nDo you use properties of the object in your hashCode override method? Also does your pull request fix the issue?\r\n\r\nThanks"}}