Why does Grails issue SELECT statements on instance save()?

梦想与她 提交于 2019-12-10 11:15:15

问题


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

来源:https://stackoverflow.com/questions/25944080/why-does-grails-issue-select-statements-on-instance-save

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!