You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
[ x] Example that reproduces the problem uploaded to Github
[ x] Full description of the issue provided (see below)
Steps to Reproduce
Create a domain class hierarchy where one domain (Review) references other domains (Product, Person) via member variables
Add a "dateCreated" property in the domain that references others (Review).
Add "beforeInsert", "afterUpdate" or any other closure event method in the domain that references others.
Create a new instance of the domain that references others (Review)
Set referenced domains by getting a hibernate proxy with the load() method.
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
The text was updated successfully, but these errors were encountered:
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
DateCreated2.zip
] Stacktrace (if present) provided
Steps to Reproduce
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
Macos 10.13.6
2.5.6
1.7.0_80
Example Application
The text was updated successfully, but these errors were encountered: