{"action":"created","issue":{"url":"https://api.github.com/repos/Wolfgang-Schuetzelhofer/jcypher/issues/7","labels_url":"https://api.github.com/repos/Wolfgang-Schuetzelhofer/jcypher/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/Wolfgang-Schuetzelhofer/jcypher/issues/7/comments","events_url":"https://api.github.com/repos/Wolfgang-Schuetzelhofer/jcypher/issues/7/events","html_url":"https://github.com/Wolfgang-Schuetzelhofer/jcypher/issues/7","id":112360202,"number":7,"title":"[Domain Mapping] Reference incoming relations","user":{"login":"nicoruti","id":4671020,"avatar_url":"https://avatars.githubusercontent.com/u/4671020?v=3","gravatar_id":"","url":"https://api.github.com/users/nicoruti","html_url":"https://github.com/nicoruti","followers_url":"https://api.github.com/users/nicoruti/followers","following_url":"https://api.github.com/users/nicoruti/following{/other_user}","gists_url":"https://api.github.com/users/nicoruti/gists{/gist_id}","starred_url":"https://api.github.com/users/nicoruti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicoruti/subscriptions","organizations_url":"https://api.github.com/users/nicoruti/orgs","repos_url":"https://api.github.com/users/nicoruti/repos","events_url":"https://api.github.com/users/nicoruti/events{/privacy}","received_events_url":"https://api.github.com/users/nicoruti/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-20T12:46:17Z","updated_at":"2015-10-21T10:49:55Z","closed_at":null,"body":"Hi Wolfgang\r\n\r\nI'm running some experiment with your library and am enjoying it's simplicity. I created a mapping that looks as follows:\r\n\r\n(Person)-[worksFor]->(Company)\r\n\r\nTherefore, I created the two classes. The Person keeps a reference to the company. However, is it possible to keep a reference to all employees in the Company class? If I use the following code, there mapper creates something like\r\n\r\n(p:Person)-[worksFor]->(Company)-[employees]->(Collection)-[c_content]->(p)\r\n\r\n\r\n```\r\npublic class Person {\r\n   public String name;\r\n   public Company worksFor;\r\n}\r\n\r\npublic class Company {\r\n   public String name;\r\n   public List<Person> employees; // --> should be same relation as Person#worksFor\r\n}\r\n```\r\n\r\nSmall test method:\r\n```\r\n@Test\r\npublic void testIncomingRelation() {\r\n    // arrange\r\n    Company company = new Company();\r\n    company.name = \"Google\";\r\n    Person person = new Person();\r\n    person.name = \"Tom\";\r\n    person.worksFor = company;\r\n    company.employees = Arrays.asList(person);\r\n\r\n    // act\r\n    domainAccess.store(person);\r\n    Company retrievedComp = domainAccess.loadById(Company.class, 1, domainAccess.getSyncInfo(company).getId());\r\n\r\n    // assert\r\n    assertThat(retrievedComp.employees, contains(person));\r\n   }\r\n```"},"comment":{"url":"https://api.github.com/repos/Wolfgang-Schuetzelhofer/jcypher/issues/comments/149852576","html_url":"https://github.com/Wolfgang-Schuetzelhofer/jcypher/issues/7#issuecomment-149852576","issue_url":"https://api.github.com/repos/Wolfgang-Schuetzelhofer/jcypher/issues/7","id":149852576,"user":{"login":"Wolfgang-Schuetzelhofer","id":7487199,"avatar_url":"https://avatars.githubusercontent.com/u/7487199?v=3","gravatar_id":"","url":"https://api.github.com/users/Wolfgang-Schuetzelhofer","html_url":"https://github.com/Wolfgang-Schuetzelhofer","followers_url":"https://api.github.com/users/Wolfgang-Schuetzelhofer/followers","following_url":"https://api.github.com/users/Wolfgang-Schuetzelhofer/following{/other_user}","gists_url":"https://api.github.com/users/Wolfgang-Schuetzelhofer/gists{/gist_id}","starred_url":"https://api.github.com/users/Wolfgang-Schuetzelhofer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wolfgang-Schuetzelhofer/subscriptions","organizations_url":"https://api.github.com/users/Wolfgang-Schuetzelhofer/orgs","repos_url":"https://api.github.com/users/Wolfgang-Schuetzelhofer/repos","events_url":"https://api.github.com/users/Wolfgang-Schuetzelhofer/events{/privacy}","received_events_url":"https://api.github.com/users/Wolfgang-Schuetzelhofer/received_events","type":"User","site_admin":false},"created_at":"2015-10-21T10:49:55Z","updated_at":"2015-10-21T10:49:55Z","body":"Hi Nico,\n\n\nJCypher, when it maps Java Object Graphs to Neo4J, maps a List or an Array to a distinct node (that's what you see).\nThis is intentional, as Lists and Arrays are themselfes objects in Java.\nIt is possible that 2 or more objects hold references to the same List instance. So when you change the content of the List, that is reflected in all objects which hold references to this List.\nWhen JCypher reads Java Object Graphs from a Neo4j database it must be able to restore exactly that state (multiple objects referencing the same list).\nThis is only possible when the List itself  is explicitly represented in the Neo4j Graph.\n\n\nHope that helps,\nbest regards,\nWolfgang\n\n\n\n-----Original Message-----\nFrom: Nico Rutishauser <notifications@github.com>\nTo: Wolfgang-Schuetzelhofer/jcypher <jcypher@noreply.github.com>\nSent: Tue, Oct 20, 2015 2:46 pm\nSubject: [jcypher] [Domain Mapping] Reference incoming relations (#7)\n\n\n\nHi Wolfgang\nI'm running some experiment with your library and am enjoying it's simplicity. I created a mapping that looks as follows:\n(Person)-[worksFor]->(Company)\nTherefore, I created the two classes. The Person keeps a reference to the company. However, is it possible to keep a reference to all employees in the Company class? If I use the following code, there mapper creates something like\n(p:Person)-[worksFor]->(Company)-[employees]->(Collection)-[c_content]->(p)\npublic class Person {\n   public String name;\n   public Company worksFor;\n}\n\npublic class Company {\n   public String name;\n   public List<Person> employees; // --> should be same relation as Person#worksFor\n}\n\nSmall test method:\n@Test\npublic void testIncomingRelation() {\n    // arrange\n    Company company = new Company();\n    company.name = \"Google\";\n    Person person = new Person();\n    person.name = \"Tom\";\n    person.worksFor = company;\n    company.setEmployees(Arrays.asList(person));\n\n    // act\n    domainAccess.store(person);\n    Company retrievedComp = domainAccess.loadById(Company.class, 1, domainAccess.getSyncInfo(company).getId());\n\n    // assert\n    assertThat(retrievedComp.getEmployees(), contains(person));\n   }\n\n—\nReply to this email directly or view it on GitHub.\n\n    \n\n\n"}}