Macoshark opened a new issue, #14546:
URL: https://github.com/apache/grails-core/issues/14546

   Grails fetches proxied domain class references from database unnecessarily 
when domain class includes the auto timestamped "dateCreated" field or any 
closure event method (beforeUpdate, afterUpdate, beforeInsert, etc). They are 
not fetched because of validation and setting validate to false during save has 
no effect. 
   
   Setting autoTimestamp to false in the domain class mapping and removing any 
closure event methods removes the problem.
   
   The problem can be reproduced on at least grails 2.4.5, 2.5.5 and 2.5.6. It 
can not be reproduced on grails 3.3.8.
   
   Tested on 
   
   ### Task List
   
   - [ x] Steps to reproduce provided
   - [ x
   
[DateCreated2.zip](https://github.com/grails/grails-core/files/2460151/DateCreated2.zip)
   ] Stacktrace (if present) provided
   - [ x] Example that reproduces the problem uploaded to Github
   - [ x] Full description of the issue provided (see below)
   
   ### Steps to Reproduce
   
   1. Create a domain class hierarchy where one domain (Review) references 
other domains (Product, Person) via member variables
   2. Add a "dateCreated" property in the domain that references others 
(Review). 
   3. Add "beforeInsert", "afterUpdate" or any other closure event method in 
the domain that references others.
   4. Create a new instance of the domain that references others (Review)
   5. Set referenced domains by getting a hibernate proxy with the load() 
method.
   6. Save the created domain instance.
   
   ### Expected Behaviour
   
   Database is accessed only once to insert the newly created domain (Review). 
Other domains (Product, Person) referenced via hibernate proxies are not 
fetched.
   
   ### Actual Behaviour
   
   All referenced domains are fetched with separate trips to the database.
   
   ### Environment Information
   
   - **Operating System**:
   Macos 10.13.6
   - **Grails Version:**
   2.5.6
   - **JDK Version:**
   1.7.0_80
   - **Container Version (If Applicable):**
   
   ### Example Application
   
   - TODO: link to github repository with example that reproduces the issue
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to