We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
select count(*)
create a where query that joins in a related class:
Don't execute the where query.
@Entity class Pet { static hasMany = [nickNames: NickName] String name } @Entity class NickName { static belongsTo = [pet: Pet] String nickname } def query = Pet.where { def tags = nickNames tags.nickname == "Spot" order("tags.nickname") }
No sql statements should be executed.
A count(*) query is executed on the relationship table. select count(*) as y0_ from nick_name this_ limit ?
count(*)
select count(*) as y0_ from nick_name this_ limit ?
https://github.com/tircnf/ExtraQuery
The only source code in the project is the following hibernateSpec which requires that sql logging be enabled in logback.groovy.
logger 'org.hibernate.SQL', DEBUG
import grails.persistence.Entity import grails.test.hibernate.HibernateSpec import org.junit.Rule import org.springframework.boot.test.rule.OutputCapture class ExtraQuerySpec extends HibernateSpec { @Rule OutputCapture capture = new OutputCapture() @Override List<Class> getDomainClasses() { return [Pet, NickName] } void testSetup() { expect: true !capture.toString() } void testLogging() { expect: new Pet(name: "jerry").save(flush: true, failOnError: true) capture.toString().contains("insert into pet") } void testCriteria() { when: "I create a detachedCriteria" Pet.where { } then: "no query is executed" !capture.toString() } void "test and query join criteria."() { when: "I create query with join and projection" Pet.where { def tags = nickNames tags.nickname == "Spot" order("tags.nickname") } then: "No query should have been executed, but count(*) from nick_name runs." !capture.toString() } } @Entity class Pet { static hasMany = [nickNames: NickName] String name } @Entity class NickName { static belongsTo = [pet: Pet] String nickname }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Task List
Steps to Reproduce
create a where query that joins in a related class:
Don't execute the where query.
Expected Behaviour
No sql statements should be executed.
Actual Behaviour
A
count(*)
query is executed on the relationship table.select count(*) as y0_ from nick_name this_ limit ?
Environment Information
Example Application
https://github.com/tircnf/ExtraQuery
The only source code in the project is the following hibernateSpec which requires that sql logging be enabled in logback.groovy.
The text was updated successfully, but these errors were encountered: