gorm


Why do these Gradle tests throw exceptions?


I've got following test
answer = Author.withCriteria {
books {
gt 'price', new DetachedCriteria(Book).build {
projections {
avg 'price'
}
}
}
}
assert answer.size() == 1
Intellij IDEA executes this test without exceptions. If I run gradle build this test rises org.hibernate.exception.SQLGrammarException: could not execute query exception.
Intellij generates following SQL:
select this_.id as id2_1_, this_.version as version2_1_, this_.age as age2_1_, this_.email as email2_1_, this_.first_name as first5_2_1_, this_.home_page as home6_2_1_, this_.last_name as last7_2_1_, this_.login as login2_1_, this_.salary as salary2_1_, this_.sex as sex2_1_, (SELECT count(*) FROM BOOK b WHERE b.author_id = this_.id) as formula0_1_, books_alia1_.id as id1_0_, books_alia1_.version as version1_0_, books_alia1_.author_id as author3_1_0_, books_alia1_.date_created as date4_1_0_, books_alia1_.last_updated as last5_1_0_, books_alia1_.price as price1_0_, books_alia1_.title as title1_0_ from author this_ inner join book books_alia1_ on this_.id=books_alia1_.author_id where (books_alia1_.price > (select avg(cast(this_.price as double)) as y0_ from book this_))
Gradle SQL:
select this_.id as id2_1_, this_.version as version2_1_, this_.age as age2_1_, this_.email as email2_1_, this_.first_name as first5_2_1_, this_.home_page as home6_2_1_, this_.last_name as last7_2_1_, this_.login as login2_1_, this_.salary as salary2_1_, this_.sex as sex2_1_, (SELECT count(*) FROM BOOK b WHERE b.author_id = this_.id) as formula0_1_, books_alia1_.id as id0_0_, books_alia1_.version as version0_0_, books_alia1_.author_id as author3_0_0_, books_alia1_.date_created as date4_0_0_, books_alia1_.last_updated as last5_0_0_, books_alia1_.price as price0_0_, books_alia1_.title as title0_0_ from author this_ inner join book books_alia1_ on this_.id=books_alia1_.author_id where (books_alia1_.price > (select from book this_)
You can see problems with avg 'price' part.
Question is the same: Why tests executed by Gradle have exceptions?
ps
Intellij dependecies are installed by gradle idea command
Only you can find out. Maybe the class paths are different (remember that IDEA doesn't have as strict a class path separation as Gradle), or the resources are different (again this works differently in IDEA compared to Gradle). First thing to do is to analyze the stack trace. Debugging the test in Gradle (-Dtest.debug=true) can also help.

Related Links

Grails 3 GORM - must have same number of columns as the referenced primary key issue
“grails.mongodb.default.mapping” equivalent in application.yml in Grails 3.2
TenantId is null when saving an entity in a Discriminator based multi tenant application in Grails 3.2 with GORM 6
Grails 3 (unsaved) instance issue while fetching from database (GORM)
Can't use get() in domain using Grails3
GORM findAll + cannot pass dynamic List as named parameter
How to display database records in grails
Configure Grails 3.0.9 for Oracle 12c with identity PK?
Adding condition to findAll and findAllBy methods
Neo4j and Mongodb as datasource in Grails
GORM (varchar .save(), non DATE): ORA-01861: literal does not match format string
GORM addTo methods not found in Spock test
spring-boot property exception while externalizing datasource properties and using actuator
Mapping hasMany relation and saving the related data
Method on class [] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails Correctly
What happens when two app servers in cluster start LiquiBase update (via Grails)?

Categories

HOME
ms-access
ibm-bluemix
variables
wso2
gis
spring-jdbc
ojdbc
opengl-es-2.0
swagger-ui
pheatmap
synchronization
gnupg
user-input
spring-xd
modx-revolution
apache-cayenne
jplayer
messages
flask-wtforms
serverless-framework
transformation
django-cms
nodatime
xlsxwriter
opencover
captiveportal
jndi
dynamic-featured-image
chromebook
brunch
typo3-6.2.x
srcset
twilio-api
uisplitview
commit
openoffice.org
y86
hexo
vxworks
main
jquery-bootgrid
sqlite2
jna
executenonquery
chain-builder
filepicker
pango
theming
promela
dandelion
capacity
memory-alignment
titanium-android
synchronous
parallel-data-warehouse
azure-virtual-network
underscore.js-templating
measures
fputcsv
holder.js
pagedlist
r-tree
retina
spidermonkey
coveralls
dukescript
splash
jsapi
python-green
relocation
socketexception
bitcoinj
openexr
has-many-through
typeof
starcluster
jquery-layout
yorick
htmlcleaner
xceed-datagrid
intentservice
c18
spring-io
dataservice
interface-orientation
limejs
sublist
gdata-api
runas
jspinclude
postgresql-performance
removeclass
whoosh
winbugs14
floating
sudzc
castle-monorail
substrings
ti-dsp
gacutil

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App