{"action":"created","issue":{"url":"https://api.github.com/repos/grails/grails-core/issues/9861","repository_url":"https://api.github.com/repos/grails/grails-core","labels_url":"https://api.github.com/repos/grails/grails-core/issues/9861/labels{/name}","comments_url":"https://api.github.com/repos/grails/grails-core/issues/9861/comments","events_url":"https://api.github.com/repos/grails/grails-core/issues/9861/events","html_url":"https://github.com/grails/grails-core/issues/9861","id":147971940,"number":9861,"title":"Grails 3 : Problem with MultiTenant Domain - Controller methods Show, Update ","user":{"login":"satshil","id":15148870,"avatar_url":"https://avatars.githubusercontent.com/u/15148870?v=3","gravatar_id":"","url":"https://api.github.com/users/satshil","html_url":"https://github.com/satshil","followers_url":"https://api.github.com/users/satshil/followers","following_url":"https://api.github.com/users/satshil/following{/other_user}","gists_url":"https://api.github.com/users/satshil/gists{/gist_id}","starred_url":"https://api.github.com/users/satshil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/satshil/subscriptions","organizations_url":"https://api.github.com/users/satshil/orgs","repos_url":"https://api.github.com/users/satshil/repos","events_url":"https://api.github.com/users/satshil/events{/privacy}","received_events_url":"https://api.github.com/users/satshil/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/grails/grails-core/labels/Duplicate","name":"Duplicate","color":"c7def8"},{"url":"https://api.github.com/repos/grails/grails-core/labels/Example%20Attached","name":"Example Attached","color":"eb6420"},{"url":"https://api.github.com/repos/grails/grails-core/labels/GORM","name":"GORM","color":"fbca04"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/grails/grails-core/milestones/165","html_url":"https://github.com/grails/grails-core/milestones/grails-3.1.6","labels_url":"https://api.github.com/repos/grails/grails-core/milestones/165/labels","id":1684352,"number":165,"title":"grails-3.1.6","description":"","creator":{"login":"graemerocher","id":66626,"avatar_url":"https://avatars.githubusercontent.com/u/66626?v=3","gravatar_id":"","url":"https://api.github.com/users/graemerocher","html_url":"https://github.com/graemerocher","followers_url":"https://api.github.com/users/graemerocher/followers","following_url":"https://api.github.com/users/graemerocher/following{/other_user}","gists_url":"https://api.github.com/users/graemerocher/gists{/gist_id}","starred_url":"https://api.github.com/users/graemerocher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/graemerocher/subscriptions","organizations_url":"https://api.github.com/users/graemerocher/orgs","repos_url":"https://api.github.com/users/graemerocher/repos","events_url":"https://api.github.com/users/graemerocher/events{/privacy}","received_events_url":"https://api.github.com/users/graemerocher/received_events","type":"User","site_admin":false},"open_issues":19,"closed_issues":2,"state":"open","created_at":"2016-04-05T11:51:09Z","updated_at":"2016-04-19T07:10:50Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2016-04-13T07:32:22Z","updated_at":"2016-04-19T07:10:50Z","closed_at":"2016-04-19T07:10:50Z","body":"Scenario\r\n---------------------\r\ngrails 3.0.10\r\nhibernate 4\r\n\r\nCreated application with 2 datasources defines ds1 and ds2\r\n\r\nDomain class Employee with datasources= ['ds1,'ds2']\r\nController class EmployeeController with method show(Employee e){...}  ,  update(Employee)\r\nScreens create.gsp, update.gsp\r\n\r\nProblem Statement\r\n---------\r\nI am able to create the record in db using employee.\"ds2\".save() that creates a row in Ds2 database\r\n\r\nbut when I call show, the instance of employee is null because grails don't understand from which db to fetch it :(\r\nSo I do following\r\n\r\n`show(){\r\nEmployee e = Employee.\"ds2\".findById(params.id)\r\n.....\r\n}\r\n`\r\nThis works fine in case of show.  But in logs I can see a call to DB which returns Nohing (may be a call made to ds1 by grails internal binding)\r\n\r\nBut the real problem arise when I try to update it.\r\n\r\nexisting code update(Employee e)\r\n...  e is null\r\n\r\n`update(){\r\nEmployee e = Employee.\"ds2\".findById(params.id)\r\ne.properties = params\r\n\r\nif(!e.isDirty()){\r\n     e.discard()\r\n     show()\r\n}\r\ne.\"ds2\".save()`\r\n\r\nThis never sets the isDirty() as true. My code always goes to discard() but the item is saved with changes().\r\nMy guess is the session does save it before the update() event is called.\r\n\r\nFixes Appllied\r\n-----------\r\n\r\nI like to understand how I can override this default loading of objects before the event.\r\n I tried doing following in bootstrap but its no use\r\n\r\n`DefaultGrailsDomainClass.metaClass.static.get = {Serializable id ->\r\n\t\t\tprintln (\"Domain Load :::::: \" + delegate + \" id = \" + id)\r\n\t\t    delegate.\"ds2\".findById(id)\r\n\t\t}`\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/grails/grails-core/issues/comments/211764668","html_url":"https://github.com/grails/grails-core/issues/9861#issuecomment-211764668","issue_url":"https://api.github.com/repos/grails/grails-core/issues/9861","id":211764668,"user":{"login":"graemerocher","id":66626,"avatar_url":"https://avatars.githubusercontent.com/u/66626?v=3","gravatar_id":"","url":"https://api.github.com/users/graemerocher","html_url":"https://github.com/graemerocher","followers_url":"https://api.github.com/users/graemerocher/followers","following_url":"https://api.github.com/users/graemerocher/following{/other_user}","gists_url":"https://api.github.com/users/graemerocher/gists{/gist_id}","starred_url":"https://api.github.com/users/graemerocher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/graemerocher/subscriptions","organizations_url":"https://api.github.com/users/graemerocher/orgs","repos_url":"https://api.github.com/users/graemerocher/repos","events_url":"https://api.github.com/users/graemerocher/events{/privacy}","received_events_url":"https://api.github.com/users/graemerocher/received_events","type":"User","site_admin":false},"created_at":"2016-04-19T07:10:50Z","updated_at":"2016-04-19T07:10:50Z","body":"Duplicates https://github.com/grails/grails-data-mapping/issues/668"}}