{"action":"created","issue":{"url":"https://api.github.com/repos/Raizlabs/DBFlow/issues/32","labels_url":"https://api.github.com/repos/Raizlabs/DBFlow/issues/32/labels{/name}","comments_url":"https://api.github.com/repos/Raizlabs/DBFlow/issues/32/comments","events_url":"https://api.github.com/repos/Raizlabs/DBFlow/issues/32/events","html_url":"https://github.com/Raizlabs/DBFlow/issues/32","id":55501174,"number":32,"title":"Save relationship with TransactionManager","user":{"login":"tsuharesu","id":808267,"avatar_url":"https://avatars.githubusercontent.com/u/808267?v=3","gravatar_id":"","url":"https://api.github.com/users/tsuharesu","html_url":"https://github.com/tsuharesu","followers_url":"https://api.github.com/users/tsuharesu/followers","following_url":"https://api.github.com/users/tsuharesu/following{/other_user}","gists_url":"https://api.github.com/users/tsuharesu/gists{/gist_id}","starred_url":"https://api.github.com/users/tsuharesu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tsuharesu/subscriptions","organizations_url":"https://api.github.com/users/tsuharesu/orgs","repos_url":"https://api.github.com/users/tsuharesu/repos","events_url":"https://api.github.com/users/tsuharesu/events{/privacy}","received_events_url":"https://api.github.com/users/tsuharesu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-01-26T16:13:38Z","updated_at":"2015-01-26T23:50:55Z","closed_at":null,"body":"I have 2 models with a One-to-Many relationship, like below:\r\n\r\n``` java\r\n@Table\r\npublic class Dashboard extends BaseModel {\r\n...\r\nList<Chart> charts;\r\n}\r\n```\r\n\r\n``` java\r\n@Table\r\npublic class Chart extends BaseModel {\r\n    ...\r\n    @Column(columnType = Column.FOREIGN_KEY, references = {@ForeignKeyReference(columnName = \"dashboard_id\", columnType = int.class, foreignColumnName = \"id\")})\r\n    Dashboard dashboard;\r\n}\r\n```\r\n\r\nAfter creating a list of dashboards with Charts, I'm saving them on a transaction with `TransactionManager.getInstance().save(ProcessModelInfo.withModels(dashboards))` my dashboards are saved but the charts inside are not. Am I missing something? Do I need to iterate through all dashboards and save charts in a similiar transaction?"},"comment":{"url":"https://api.github.com/repos/Raizlabs/DBFlow/issues/comments/71563557","html_url":"https://github.com/Raizlabs/DBFlow/issues/32#issuecomment-71563557","issue_url":"https://api.github.com/repos/Raizlabs/DBFlow/issues/32","id":71563557,"user":{"login":"agrosner","id":2117859,"avatar_url":"https://avatars.githubusercontent.com/u/2117859?v=3","gravatar_id":"","url":"https://api.github.com/users/agrosner","html_url":"https://github.com/agrosner","followers_url":"https://api.github.com/users/agrosner/followers","following_url":"https://api.github.com/users/agrosner/following{/other_user}","gists_url":"https://api.github.com/users/agrosner/gists{/gist_id}","starred_url":"https://api.github.com/users/agrosner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agrosner/subscriptions","organizations_url":"https://api.github.com/users/agrosner/orgs","repos_url":"https://api.github.com/users/agrosner/repos","events_url":"https://api.github.com/users/agrosner/events{/privacy}","received_events_url":"https://api.github.com/users/agrosner/received_events","type":"User","site_admin":false},"created_at":"2015-01-26T23:50:55Z","updated_at":"2015-01-26T23:50:55Z","body":"sorry I meant ``onExecute()```. The ```TransactionManager``` simply adds the object to the ````DBTransactionQueue``` and that's how the transactions are processed. The base class, ```ProcessModelTransaction```, will wrap the ```onExecute()``` call within a single Transaction.\r\n\r\nYes, there are a few ways to do something in this library, and usually it comes down to personal preference. \r\n\r\nThe simplest solution without using begin and end transaction is simply (in Dashboard.java):\r\n\r\n```java\r\npublic void save(boolean async) {\r\n  super.save(async);\r\n  for(Chart chart: charts) {\r\n    chart.save(false);\r\n  }\r\n}\r\n\r\n```\r\n"}}