Why does Grails issue SELECT statements on instanc

2019-05-29 01:23发布

问题:

Each time I save() a new domain object in Grails I see Hibernate issuing Select statements for each of the unique constraints in my Grails domain class.

If I save without validation, I don't see the Select statements. Example:

new Person(name: 'Foo').save(validate: false)

Is there a way to stop these extra Select statements from occurring while still having validation enabled?

One of my goals is to decrease appserver/database chattiness since I am expecting my Grails app to run on a high latency network (e.g., communicating from Grails app => DB can be costly).

Burt has one suggestion, but I'm hoping for something easier/cleaner:

  • Grails save() Domain Object actually does a Select?

This may be a Hibernate issue more than Grails. I'm not sure.

Maybe some other related info:

  • Why does hibernate do the SELECT before SAVE?
  • select Query Run for hibernateTemplate.save()
  • Force Hibernate Insert Without Select Statements