{"action":"created","issue":{"url":"https://api.github.com/repos/grails/grails-core/issues/9749","repository_url":"https://api.github.com/repos/grails/grails-core","labels_url":"https://api.github.com/repos/grails/grails-core/issues/9749/labels{/name}","comments_url":"https://api.github.com/repos/grails/grails-core/issues/9749/comments","events_url":"https://api.github.com/repos/grails/grails-core/issues/9749/events","html_url":"https://github.com/grails/grails-core/issues/9749","id":137644298,"number":9749,"title":"[3.1.2] - validate() method on Domain class causes getXyz() methods without parameters to be called","user":{"login":"droggo","id":3313302,"avatar_url":"https://avatars.githubusercontent.com/u/3313302?v=3","gravatar_id":"","url":"https://api.github.com/users/droggo","html_url":"https://github.com/droggo","followers_url":"https://api.github.com/users/droggo/followers","following_url":"https://api.github.com/users/droggo/following{/other_user}","gists_url":"https://api.github.com/users/droggo/gists{/gist_id}","starred_url":"https://api.github.com/users/droggo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/droggo/subscriptions","organizations_url":"https://api.github.com/users/droggo/orgs","repos_url":"https://api.github.com/users/droggo/repos","events_url":"https://api.github.com/users/droggo/events{/privacy}","received_events_url":"https://api.github.com/users/droggo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/grails/grails-core/labels/Acknowledged","name":"Acknowledged","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-03-01T17:59:59Z","updated_at":"2016-03-01T18:41:38Z","closed_at":null,"body":"After upgrade to 3.1.2 it seems that all getters in domains classes are considered constrained properties and are called during validatation. Even if method is marked `transient` or 'property' is added to `transients` list.\r\n\r\nThis is a big issue for us, application will not start, a lot of tests are failing, and this will also strongly influence performance. Please let us know if we should start refactoring to change method names or this is not planned and is a bug.\r\n\r\nApplication startup issue. Using spring-security plugin, we use `RoleGroup` class which has a getter for authorities - `getRoles()` (executing database query). When RoleGroup is saved, following error is thrown:\r\n```\r\norg.springframework.beans.InvalidPropertyException: Invalid property 'roles' of bean class [some.package.RoleGroup]: Getter for property 'roles' threw exception; nested exception is java.lang.reflect.InvocationTargetException\r\n        at org.springframework.beans.AbstractNestablePropertyAccessor.getPropertyValue(AbstractNestablePropertyAccessor.java:704) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]\r\n        at org.springframework.beans.AbstractNestablePropertyAccessor.getPropertyValue(AbstractNestablePropertyAccessor.java:610) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]\r\n        at org.grails.validation.GrailsDomainClassValidator.validatePropertyWithConstraint(GrailsDomainClassValidator.java:211) ~[grails-validation-3.1.2.jar:3.1.2]\r\n        at org.grails.validation.GrailsDomainClassValidator.validate(GrailsDomainClassValidator.java:81) ~[grails-validation-3.1.2.jar:3.1.2]\r\n        at org.grails.orm.hibernate.AbstractHibernateGormInstanceApi.save(AbstractHibernateGormInstanceApi.groovy:122) ~[grails-datastore-gorm-hibernate-core-5.0.2.RELEASE.jar:na]\r\n        at org.grails.datastore.gorm.GormEntity$Trait$Helper.save(GormEntity.groovy:140) ~[grails-datastore-gorm-5.0.2.RELEASE.jar:na]\r\n        at org.grails.datastore.gorm.GormEntity$Trait$Helper$save$1.call(Unknown Source) ~[na:na]\r\n        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) [groovy-2.4.6.jar:2.4.6]\r\n        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) [groovy-2.4.6.jar:2.4.6]\r\n        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133) [groovy-2.4.6.jar:2.4.6]\r\n        at some.package.RoleGroup.save(RoleGroup.groovy) \r\n        at some.package.RoleGroup.save(RoleGroup.groovy) \r\n        at org.grails.datastore.gorm.GormEntity$save.call(Unknown Source) ~[na:na]\r\n        at org.codehaus.groovy.runtime.callsiteteArray.defaultCall(CallSiteArray.java:48) [groovy-2.4.6.jar:2.4.6]\r\n        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) [groovy-2.4.6.jar:2.4.6]\r\n        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) [groovy-2.4.6.jar:2.4.6]\r\n        at some.package.UserService.createRoleGroup(UserService.groovy:75) \r\n```\r\n\r\nPerformance impact example:\r\n```\r\nclass SomeDomain {\r\n    transient Collection getImages(){\r\n        AnotherDomain.findAllBySomeDomain(this)\r\n    }\r\n}\r\n```\r\nSince 3.1.2 of every validation of SomeDomain, query will be done to fetch all AnotherDomain objects.\r\n\r\nIf getter throws exception, which happens for some of our getter methods following error is logged: :\r\n```\r\norg.springframework.beans.InvalidPropertyException: Invalid property 'someProperty' of bean class [SomeDomain]: Getter for property 'someProperty' threw exception; nested exception is java.lang.reflect.InvocationTargetException\r\n\tat org.springframework.beans.AbstractNestablePropertyAccessor.getPropertyValue(AbstractNestablePropertyAccessor.java:704)\r\n\tat org.springframework.beans.AbstractNestablePropertyAccessor.getPropertyValue(AbstractNestablePropertyAccessor.java:610)\r\n\tat org.grails.validation.GrailsDomainClassValidator.validatePropertyWithConstraint(GrailsDomainClassValidator.java:211)\r\n\tat org.grails.validation.GrailsDomainClassValidator.validate(GrailsDomainClassValidator.java:81)\r\n\tat org.grails.datastore.gorm.GormValidationApi.doValidate(GormValidationApi.groovy:89)\r\n\tat org.grails.datastore.gorm.GormValidationApi.validate(GormValidationApi.groovy:161)\r\n\tat org.grails.datastore.gorm.GormValidateable$Trait$Helper.validate(GormValidateable.groovy:87)\r\n\tat org.grails.datastore.gorm.GormInstanceApi.doSave(GormInstanceApi.groovy:181)\r\n\tat org.grails.datastore.gorm.GormInstanceApi.save_closure5(GormInstanceApi.groovy:170)\r\n\tat groovy.lang.Closure.call(Closure.java:426)\r\n\tat org.grails.datastore.mapping.core.DatastoreUtils.execute(DatastoreUtils.java:310)\r\n\tat org.grails.datastore.gorm.AbstractDatastoreApi.execute(AbstractDatastoreApi.groovy:37)\r\n\tat org.grails.datastore.gorm.GormInstanceApi.save(GormInstanceApi.groovy:169)\r\n\tat org.grails.datastore.gorm.GormInstanceApi.save(GormInstanceApi.groovy:109)\r\n\tat org.grails.datastore.gorm.GormEntity$Trait$Helper.save(GormEntity.groovy:87)\r\n```"},"comment":{"url":"https://api.github.com/repos/grails/grails-core/issues/comments/190846870","html_url":"https://github.com/grails/grails-core/issues/9749#issuecomment-190846870","issue_url":"https://api.github.com/repos/grails/grails-core/issues/9749","id":190846870,"user":{"login":"droggo","id":3313302,"avatar_url":"https://avatars.githubusercontent.com/u/3313302?v=3","gravatar_id":"","url":"https://api.github.com/users/droggo","html_url":"https://github.com/droggo","followers_url":"https://api.github.com/users/droggo/followers","following_url":"https://api.github.com/users/droggo/following{/other_user}","gists_url":"https://api.github.com/users/droggo/gists{/gist_id}","starred_url":"https://api.github.com/users/droggo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/droggo/subscriptions","organizations_url":"https://api.github.com/users/droggo/orgs","repos_url":"https://api.github.com/users/droggo/repos","events_url":"https://api.github.com/users/droggo/events{/privacy}","received_events_url":"https://api.github.com/users/droggo/received_events","type":"User","site_admin":false},"created_at":"2016-03-01T18:41:38Z","updated_at":"2016-03-01T18:41:38Z","body":"Unfortunatelly I was wrong. The issue for Mongo is even worse, as it happens for all unit tests which do something with domain objects. Please see stacktrace below:\r\n\r\n```\r\norg.springframework.beans.InvalidPropertyException: Invalid property 'dbo' of bean class [some.package.Price]: Getter for property 'dbo' threw exception; nested exception is java.lang.reflect.InvocationTargetException\r\n\tat org.springframework.beans.AbstractNestablePropertyAccessor.getPropertyValue(AbstractNestablePropertyAccessor.java:704)\r\n\tat org.springframework.beans.AbstractNestablePropertyAccessor.getPropertyValue(AbstractNestablePropertyAccessor.java:610)\r\n\tat org.grails.validation.GrailsDomainClassValidator.validatePropertyWithConstraint(GrailsDomainClassValidator.java:211)\r\n\tat org.grails.validation.GrailsDomainClassValidator.validate(GrailsDomainClassValidator.java:81)\r\n\tat org.grails.datastore.gorm.GormValidationApi.doValidate(GormValidationApi.groovy:89)\r\n\tat org.grails.datastore.gorm.GormValidationApi.validate(GormValidationApi.groovy:161)\r\n\tat org.grails.datastore.gorm.GormValidateable$Trait$Helper.validate(GormValidateable.groovy:87)\r\n\tat org.grails.datastore.gorm.GormInstanceApi.doSave(GormInstanceApi.groovy:181)\r\n\tat org.grails.datastore.gorm.GormInstanceApi.save_closure5(GormInstanceApi.groovy:170)\r\n\tat groovy.lang.Closure.call(Closure.java:426)\r\n\tat org.grails.datastore.mapping.core.DatastoreUtils.execute(DatastoreUtils.java:310)\r\n\tat org.grails.datastore.gorm.AbstractDatastoreApi.execute(AbstractDatastoreApi.groovy:37)\r\n\tat org.grails.datastore.gorm.GormInstanceApi.save(GormInstanceApi.groovy:169)\r\n\tat org.grails.datastore.gorm.GormInstanceApi.save(GormInstanceApi.groovy:109)\r\n\tat org.grails.datastore.gorm.GormEntity$Trait$Helper.save(GormEntity.groovy:87)\r\n\tat some.package.PriceControllerSpec.testUpdate(PriceControllerSpec.groovy:133)\r\nCaused by: java.lang.reflect.InvocationTargetException\r\n\tat org.springframework.beans.BeanWrapperImpl$BeanPropertyHandler.getValue(BeanWrapperImpl.java:307)\r\n\tat org.springframework.beans.AbstractNestablePropertyAccessor.getPropertyValue(AbstractNestablePropertyAccessor.java:622)\r\n\t... 15 more\r\nCaused by: org.grails.datastore.mapping.core.ConnectionNotFoundException: No datastore session found. Call Datastore.connect(..) before calling Datastore.getCurrentSession()\r\n\tat org.grails.datastore.mapping.core.AbstractDatastore.retrieveSession(AbstractDatastore.java:207)\r\n\tat grails.mongodb.MongoEntity$Trait$Helper.getDbo(MongoEntity.groovy:149)\r\n\t... 17 more\r\n```\r\n\r\n`getDbo()` method is from `grails.mongodb.MongoEntity` trait from mongo plugin and it definitely shouldn't be verified by validation on save. I will create empty Grails 3.1.2 project and verify it, because maybe there some additional configuration needed when upgrading from 3.1.1?"}}