{"action":"created","issue":{"url":"https://api.github.com/repos/katharsis-project/katharsis-core/issues/204","labels_url":"https://api.github.com/repos/katharsis-project/katharsis-core/issues/204/labels{/name}","comments_url":"https://api.github.com/repos/katharsis-project/katharsis-core/issues/204/comments","events_url":"https://api.github.com/repos/katharsis-project/katharsis-core/issues/204/events","html_url":"https://github.com/katharsis-project/katharsis-core/issues/204","id":125422944,"number":204,"title":"Related resources not fetched","user":{"login":"ashishgodani","id":1346417,"avatar_url":"https://avatars.githubusercontent.com/u/1346417?v=3","gravatar_id":"","url":"https://api.github.com/users/ashishgodani","html_url":"https://github.com/ashishgodani","followers_url":"https://api.github.com/users/ashishgodani/followers","following_url":"https://api.github.com/users/ashishgodani/following{/other_user}","gists_url":"https://api.github.com/users/ashishgodani/gists{/gist_id}","starred_url":"https://api.github.com/users/ashishgodani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashishgodani/subscriptions","organizations_url":"https://api.github.com/users/ashishgodani/orgs","repos_url":"https://api.github.com/users/ashishgodani/repos","events_url":"https://api.github.com/users/ashishgodani/events{/privacy}","received_events_url":"https://api.github.com/users/ashishgodani/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-01-07T16:04:04Z","updated_at":"2016-01-09T00:09:29Z","closed_at":null,"body":"I am trying my hands-on katharsis and I and a little confused with the way a composed objects are fetched. A sample scenarios goes like: I would like to fetch project details along with the task in one go so 'data' should have the value for the project ```{\"id\": \"10\",\"name\": \"test project\"}```. Expected sample response will look like (using spring-boot-simple-example): \r\n```json\r\n{\r\n\"data\": {\r\n\"type\": \"tasks\",\r\n\"id\": \"10\",\r\n\"attributes\": {\r\n\"my-name\": \"Some task\"\r\n},\r\n\"relationships\": {\r\n\"project\": {\r\n\"links\": {\r\n\"self\": \"http://localhost:8080/tasks/10/relationships/project\",\r\n\"related\": \"http://localhost:8080/tasks/10/project\"\r\n},\r\n\"data\": {\"id\": \"10\",\"name\": \"test project\"}\r\n}\r\n},\r\n\"links\": {\r\n\"self\": \"http://localhost:8080/tasks/10\"\r\n}\r\n},\r\n\"included\": []\r\n}\r\n```\r\nHow do I achieve this ? I tried the samples available in the repo but none of them seems to cater to this requirement. I was hoping that JsonApiIncludeByDefault would do this but it doesnt fetch the complex type attributes or I am doing something wrong:\r\n```java\r\n    public class Task {\r\n\r\n    @JsonApiId\r\n    private Long id;\r\n\r\n    @JsonProperty(\"my-name\")\r\n    private String name;\r\n\r\n    @JsonApiToOne\r\n    @JsonApiIncludeByDefault\r\n    private Project project;\r\n\r\n```\r\n\r\nAppreciate any help in this regard - prefer an example if possible.\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/katharsis-project/katharsis-core/issues/comments/170161994","html_url":"https://github.com/katharsis-project/katharsis-core/issues/204#issuecomment-170161994","issue_url":"https://api.github.com/repos/katharsis-project/katharsis-core/issues/204","id":170161994,"user":{"login":"ashishgodani","id":1346417,"avatar_url":"https://avatars.githubusercontent.com/u/1346417?v=3","gravatar_id":"","url":"https://api.github.com/users/ashishgodani","html_url":"https://github.com/ashishgodani","followers_url":"https://api.github.com/users/ashishgodani/followers","following_url":"https://api.github.com/users/ashishgodani/following{/other_user}","gists_url":"https://api.github.com/users/ashishgodani/gists{/gist_id}","starred_url":"https://api.github.com/users/ashishgodani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashishgodani/subscriptions","organizations_url":"https://api.github.com/users/ashishgodani/orgs","repos_url":"https://api.github.com/users/ashishgodani/repos","events_url":"https://api.github.com/users/ashishgodani/events{/privacy}","received_events_url":"https://api.github.com/users/ashishgodani/received_events","type":"User","site_admin":false},"created_at":"2016-01-09T00:09:29Z","updated_at":"2016-01-09T00:09:29Z","body":"Thanks again for the response!\r\n\r\nIt still doesnt work if the full composition is not persisted in the database. Basically I commented ```repo.put(entity.getId(), entity);``` in ```TaskRepository.save()``` method in the repo as I dont want to persist the full composition into the DB.\r\n\r\nand I modified ```initialize()``` to ```task.setProject(project)``` then call save to initialise the relationship between the two resources:\r\n```java\r\npublic class InitilizeRepo {\r\n\r\n    // ...\r\n\r\n    @PostConstruct\r\n    public void initialize() {\r\n\r\n        Task taskThree = new Task(3L, \"Task Three\");\r\n        Project projectThree = new Project(3L, \"Project Three\");\r\n        taskThree.setProject(projectThree);\r\n        taskRepository.save(taskThree);\r\n    }\r\n}\r\n```\r\n[SpringBootSampleCode_update1.zip](https://github.com/katharsis-project/katharsis-core/files/83434/SpringBootSampleCode_update1.zip)"}}