{"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":3,"created_at":"2015-10-06T17:23:48Z","updated_at":"2015-10-13T08:53:12Z","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/147652150","html_url":"https://github.com/Stuart-campbell/RushOrm/issues/78#issuecomment-147652150","issue_url":"https://api.github.com/repos/Stuart-campbell/RushOrm/issues/78","id":147652150,"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},"created_at":"2015-10-13T08:53:12Z","updated_at":"2015-10-13T08:53:12Z","body":"This is my hashcode (only strings and integers, no children): \r\n```java\r\n @Override\r\n    public int hashCode() {\r\n        int result = filmID.hashCode();\r\n        result = 31 * result + tittel.hashCode();\r\n        result = 31 * result + format.hashCode();\r\n        result = 31 * result + lagtTil.hashCode();\r\n        result = 31 * result + brukerID;\r\n        result = 31 * result + type.hashCode();\r\n        result = 31 * result + year.hashCode();\r\n        result = 31 * result + rated.hashCode();\r\n        result = 31 * result + released.hashCode();\r\n        result = 31 * result + runtime.hashCode();\r\n        result = 31 * result + genre.hashCode();\r\n        result = 31 * result + director.hashCode();\r\n        result = 31 * result + writer.hashCode();\r\n        result = 31 * result + actor.hashCode();\r\n        result = 31 * result + tagline.hashCode();\r\n        result = 31 * result + plot.hashCode();\r\n        result = 31 * result + trailer.hashCode();\r\n        result = 31 * result + imdb_id.hashCode();\r\n        result = 31 * result + trakt_id.hashCode();\r\n        result = 31 * result + poster.hashCode();\r\n        result = 31 * result + ut.hashCode();\r\n        result = 31 * result + dato.hashCode();\r\n        result = 31 * result + utlanID.hashCode();\r\n        result = 31 * result + navn.hashCode();\r\n        result = 31 * result + (err_msg != null ? err_msg.hashCode() : 0);\r\n        return result;\r\n    }\r\n```"}}