{"action":"opened","issue":{"url":"https://api.github.com/repos/grails/grails-core/issues/9846","repository_url":"https://api.github.com/repos/grails/grails-core","labels_url":"https://api.github.com/repos/grails/grails-core/issues/9846/labels{/name}","comments_url":"https://api.github.com/repos/grails/grails-core/issues/9846/comments","events_url":"https://api.github.com/repos/grails/grails-core/issues/9846/events","html_url":"https://github.com/grails/grails-core/issues/9846","id":146411592,"number":9846,"title":"[3.1.4] Embedded fields incorrectly mapped in queries","user":{"login":"coIIector","id":10324306,"avatar_url":"https://avatars.githubusercontent.com/u/10324306?v=3","gravatar_id":"","url":"https://api.github.com/users/coIIector","html_url":"https://github.com/coIIector","followers_url":"https://api.github.com/users/coIIector/followers","following_url":"https://api.github.com/users/coIIector/following{/other_user}","gists_url":"https://api.github.com/users/coIIector/gists{/gist_id}","starred_url":"https://api.github.com/users/coIIector/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coIIector/subscriptions","organizations_url":"https://api.github.com/users/coIIector/orgs","repos_url":"https://api.github.com/users/coIIector/repos","events_url":"https://api.github.com/users/coIIector/events{/privacy}","received_events_url":"https://api.github.com/users/coIIector/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-06T19:36:23Z","updated_at":"2016-04-06T19:36:23Z","closed_at":null,"body":"domain class Person (from [documentation](http://grails.github.io/grails-doc/3.1.4/ref/Domain%20Classes/embedded.html)):\r\n\r\n```\r\nclass Person {\r\n    String name\r\n    Country bornInCountry\r\n\r\n    static embedded = ['bornInCountry']\r\n}\r\n\r\nclass Country {\r\n    String name\r\n}\r\n```\r\n\r\n\r\nIn queries on **Person.name**, **Person.bornInCountry.name** is used instead.\r\n\r\neg. `Person.countByNameIsNotNull()` produces this sql code: \r\n\r\n```\r\nselect\r\n    count(*) as y0_ \r\nfrom\r\n    person this_ \r\nwhere\r\n    this_.born_in_country_name is not null\r\n```\r\n\r\n\r\n(Same thing happens when using Person.withCriteria, session.createCriteria etc.) \r\ntested in 3.1.4 and 2.5.4"}}