{"action":"created","issue":{"url":"https://api.github.com/repos/Stuart-campbell/RushOrm/issues/61","labels_url":"https://api.github.com/repos/Stuart-campbell/RushOrm/issues/61/labels{/name}","comments_url":"https://api.github.com/repos/Stuart-campbell/RushOrm/issues/61/comments","events_url":"https://api.github.com/repos/Stuart-campbell/RushOrm/issues/61/events","html_url":"https://github.com/Stuart-campbell/RushOrm/issues/61","id":96932502,"number":61,"title":"Return rows from a child table that aren't connected to a parent?","user":{"login":"ggunders","id":13426442,"avatar_url":"https://avatars.githubusercontent.com/u/13426442?v=3","gravatar_id":"","url":"https://api.github.com/users/ggunders","html_url":"https://github.com/ggunders","followers_url":"https://api.github.com/users/ggunders/followers","following_url":"https://api.github.com/users/ggunders/following{/other_user}","gists_url":"https://api.github.com/users/ggunders/gists{/gist_id}","starred_url":"https://api.github.com/users/ggunders/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ggunders/subscriptions","organizations_url":"https://api.github.com/users/ggunders/orgs","repos_url":"https://api.github.com/users/ggunders/repos","events_url":"https://api.github.com/users/ggunders/events{/privacy}","received_events_url":"https://api.github.com/users/ggunders/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-07-24T00:21:08Z","updated_at":"2015-07-24T22:02:10Z","closed_at":null,"body":"Lets say i have a data model like this:\r\n\r\n    public class woman{\r\n    private String name;\r\n    private Breast left_breast;\r\n    private Breast right_breast;\r\n    ... more (_id), etc\r\n    }\r\n\r\n    public Breast{\r\n    private String size;\r\n    private String Manufacturer;\r\n    private String fillType;\r\n    .... more (_id), etc\r\n    }\r\n\r\nThe server feeds the app women with breasts, where woman and breasts have a unique server ID(not shown). in some parts of the app, i want to show the woman with the correct breasts. but in another part of the app i want to just show breasts. \r\n\r\nbreasts are child elements of women, but are also loaded independently from the server so that all the breast types are viewable on the app.\r\n\r\nwhen i do RushSearch.find(Breast.class) i get lots of duplicates because breasts are loaded by the parent and seperately from the server sync service.\r\n\r\nhow can i just get a unique list of breasts, is there a way to do a RushSearch().whereParentless() - something that gives me all the breasts that arent connected to a woman/parent? maybe i want a unique android spinner of all the breast types.\r\n\r\nor should i be loading the breasts table first, then load the woman table and do a lookup on every woman object that comes in from the network service and find the breast child element first, assign it to the woman object and save it? \r\n\r\nif two women have the exact same breasts, should they both be connected to the same child element or should i be creating duplicate breast child elements.\r\n\r\nbased on the response to this post, ill get into adding a Man class with the need for those Breast child element.  - thx Kardashians\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Stuart-campbell/RushOrm/issues/comments/124740385","html_url":"https://github.com/Stuart-campbell/RushOrm/issues/61#issuecomment-124740385","issue_url":"https://api.github.com/repos/Stuart-campbell/RushOrm/issues/61","id":124740385,"user":{"login":"ggunders","id":13426442,"avatar_url":"https://avatars.githubusercontent.com/u/13426442?v=3","gravatar_id":"","url":"https://api.github.com/users/ggunders","html_url":"https://github.com/ggunders","followers_url":"https://api.github.com/users/ggunders/followers","following_url":"https://api.github.com/users/ggunders/following{/other_user}","gists_url":"https://api.github.com/users/ggunders/gists{/gist_id}","starred_url":"https://api.github.com/users/ggunders/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ggunders/subscriptions","organizations_url":"https://api.github.com/users/ggunders/orgs","repos_url":"https://api.github.com/users/ggunders/repos","events_url":"https://api.github.com/users/ggunders/events{/privacy}","received_events_url":"https://api.github.com/users/ggunders/received_events","type":"User","site_admin":false},"created_at":"2015-07-24T22:02:10Z","updated_at":"2015-07-24T22:02:10Z","body":"The app flow is that a woman is built in a wizard, where breast objects are selected. but the wizard just knows about the breast names not the breast id, so a lookup is required. i can reproduce without a lookup. see below\r\n\r\nI can include the classes, but they are pretty minimal.\r\n           \r\n     // clear tables\r\n        RushCore.getInstance().deleteAll(Woman.class);\r\n        RushCore.getInstance().deleteAll(Breast.class);\r\n      // load up the breasts\r\n\r\n        Breast b1 = new Breast(1,\"A\");\r\n        Breast b2 = new Breast(2,\"B\");\r\n\r\n        RushCore.getInstance().registerObjectWithId(b1, String.valueOf(b1.getServerID()));\r\n        RushCore.getInstance().registerObjectWithId(b2, String.valueOf(b2.getServerID()));\r\n\r\n        b1.save();\r\n        b2.save();\r\n\r\n        // load women\r\n\r\n        Woman betty = new Woman();\r\n        betty.setAge(22);\r\n        betty.setName(\"betty\");\r\n        betty.setlBreast(b1);\r\n        betty.setrBreast(b1);\r\n        betty.setServerID(12);// not important now\r\n        betty.save();\r\n\r\n        Woman wilma = new Woman();\r\n        wilma.setName(\"Wilma\");\r\n        wilma.setAge(32);\r\n        wilma.setlBreast(b1);\r\n        wilma.setrBreast(b1);\r\n        betty.setServerID(13);// not important now\r\n        wilma.save();\r\n\r\n        // get all the ladies\r\n        List<Woman> ladies = new RushSearch().find(Woman.class);\r\n\r\n        System.out.println(ladies.toString());\r\n\r\nOutput:\r\nI/System.out﹕ Initializing RUSH ORM!!\r\nI/System.out﹕ [Woman{serverID=12, name='betty', age=22, lBreast=null, rBreast=Breast{serverID=1, size='A'}}, Woman{serverID=0, name='Wilma', age=32, lBreast=null, rBreast=Breast{serverID=1, size='A'}}]\r\n07-24 21:38:35.267  22688-22723/com.threetwofour.plasticsurgery D/OpenGLRenderer﹕ \r\n\r\n\r\nNotice how lBreast is null for both ladies?\r\n\r\nif i set both ladies up for different breasts (per woman) it works:\r\n\r\n        betty.setlBreast(b1);\r\n        betty.setrBreast(b2);\r\n\r\n        betty.setlBreast(b1);\r\n        betty.setrBreast(b2);\r\n\r\nstrangly enough when i switch back and forth between setting the breasts the same vs different i get the following until i erase rush.db and the NPE exception goes away. if i dont erase the rush.db file, this exception keeps popping.\r\n\r\n     Process: com.threetwofour.plasticsurgery, PID: 17327\r\n    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.threetwofour.plasticsurgery/com.threetwofour.plasticsurgery.MainActivity}: java.lang.NullPointerException: Null pointer exception during instruction 'invoke-static {v4}, co.uk.rushorm.core.Rush co.uk.rushorm.core.implementation.ReflectionClassLoader$Join.access$100(co.uk.rushorm.core.implementation.ReflectionClassLoader$Join) // method@551'\r\n            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)\r\n            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)\r\n            at android.app.ActivityThread.access$800(ActivityThread.java:144)\r\n            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)\r\n            at android.os.Handler.dispatchMessage(Handler.java:102)\r\n            at android.os.Looper.loop(Looper.java:135)\r\n            at android.app.ActivityThread.main(ActivityThread.java:5221)\r\n            at java.lang.reflect.Method.invoke(Native Method)\r\n            at java.lang.reflect.Method.invoke(Method.java:372)\r\n            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)\r\n            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)\r\n         Caused by: java.lang.NullPointerException: Null pointer exception during instruction 'invoke-static {v4}, co.uk.rushorm.core.Rush co.uk.rushorm.core.implementation.ReflectionClassLoader$Join.access$100(co.uk.rushorm.core.implementation.ReflectionClassLoader$Join) // method@551'\r\n            at co.uk.rushorm.core.implementation.ReflectionClassLoader$1$1.attach(ReflectionClassLoader.java:195)\r\n            at co.uk.rushorm.core.implementation.ReflectionClassLoader.loadClasses(ReflectionClassLoader.java:57)\r\n            at co.uk.rushorm.core.implementation.ReflectionClassLoader$1.doAction(ReflectionClassLoader.java:183)\r\n            at co.uk.rushorm.core.implementation.ReflectionClassLoader.doLoop(ReflectionClassLoader.java:257)\r\n            at co.uk.rushorm.core.implementation.ReflectionClassLoader.addChildrenToList(ReflectionClassLoader.java:158)\r\n            at co.uk.rushorm.core.implementation.ReflectionClassLoader.loadClasses(ReflectionClassLoader.java:63)\r\n            at co.uk.rushorm.core.implementation.ReflectionClassLoader.loadClasses(ReflectionClassLoader.java:42)\r\n            at co.uk.rushorm.core.RushCore.load(RushCore.java:608)\r\n            at co.uk.rushorm.core.RushCore.load(RushCore.java:257)\r\n            at co.uk.rushorm.core.RushSearch.find(RushSearch.java:41)\r\n            at com.threetwofour.plasticsurgery.MainActivity.onCreate(MainActivity.java:56)\r\n            at android.app.Activity.performCreate(Activity.java:5933)\r\n            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)\r\n            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)\r\n            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)\r\n            at android.app.ActivityThread.access$800(ActivityThread.java:144)\r\n            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)\r\n            at android.os.Handler.dispatchMessage(Handler.java:102)\r\n            at android.os.Looper.loop(Looper.java:135)\r\n            at android.app.ActivityThread.main(ActivityThread.java:5221)\r\n            at java.lang.reflect.Method.invoke(Native Method)\r\n            at java.lang.reflect.Method.invoke(Method.java:372)\r\n            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)\r\n            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)\r\n\r\n\r\nversion 1.1.7"}}