gorm


GORM methods are not accessible in Domain and Service classes


UPDATED:
I have installed grails 2.0
I have got two Domain classesApplicationConfiguration and City ,
ApplicationConfiguration stores the defaults fields and their values
City will access the ApplicationConfiguration value
class ApplicationConfiguration {
String myDefaultField
String value
static getMyDefaultCity(){
def city_id = ApplicationConfiguration.findByMyDefaultField('city') .id
def cityName = ApplicationConfiguration.get(city_id ).value
}
}
Class City{
def ApplicationConfiguration
String city = ApplicationConfiguration.getMyDefaultCity()
}
Basically I am not able to access the GORM Methods form the Domain and Service such as
1) executeQuery()
2) find*()
And I get the error as below
... 5 more
Caused by: org.hibernate.InstantiationException: could not instantiate test objectCity
... 5 more
Caused by: java.lang.reflect.InvocationTargetException
... 5 more
Caused by: groovy.lang.MissingMethodException: No signature of method: ApplicationConfiguration.findByMyDefaultFie
ld() is applicable for argument types: (java.lang.String) values: [city]
at ApplicationConfiguration.getMyDefaultCity(ApplicationConfiguration.groovy:63)
at City.<init>(City.groovy:28)
and when i do ApplicationConfiguration.findByMyDefaultField('city') in my controller it works fine, GORM Methods are accessible in controllers
The test case to reproduce the bug is
1) Create a project using grails project wizard
2) Create two domain classes ApplicationConfiguration(String myDefaultField, String value) and City(String city)
3) Do generate-all for ApplicationConfiguration
4) Now add this "getMyDefaultCity()" with the definition method as shown above
5) Initialize the filed city in City domain class "String city = ApplicationConfiguration.getMyDefaultCity()"
6) Restart the application
Perhaps this question could be useful to you: Adding business logic to a domain class using a getter style method name
Have you used a transient declaration for the method?

Related Links

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)?
use of mappedBy in Many to Many relationship in Grails
Domain class auto validation in grails
Grails Detached Criteria Query and “group by” and “having” clause
Script for saving large no of entries in mongodb
Does the multiple datasource feature of Grails 2.0 support relations?
How to avoid ImprovedNamingStrategy in joinTable in Grails

Categories

HOME
image
openstack
reflection
json.net
hp-exstream
objectgears
q
rdf
jgroups
binary-tree
sql-server-2016
pivotal-cloud-foundry
node-notifier
numeral.js
google-cloud-ml
alignment
serverless-framework
ghc
progressive-web-apps
solaris-10
ab-testing
interop
riot.js
physics-engine
wijmo
rundeck
su
django-storage
selectedindexchanged
facebook-access-token
maxmind
subdomains
newline
fabric8
javascriptcore
ecto
phonegap
http-status-code-503
twilio-api
fog
azure-sql-database
environment-modules
overriding
android-ble
adobe-premiere
space-complexity
android-browser
hue
temporary-files
acoustics
executenonquery
dotcover
blogengine.net
togetherjs
lift-json
pg-dump
libusb-win32
nsarray
media-player
python-cryptography
flutterwave
yt-project
abcpdf9
etsy
bstr
moveit
yaws
wso2cloud
reactive-banana
intel-fortran
lemon
endeca-workbench
ruby-2.2
tmuxinator
deis
fluid-dynamics
sniffer
remobjects
pretty-print
system.reflection
dia
gui-test-framework
android-imagebutton
mesa
tld
picturefill
meteor-velocity
uv-mapping
page-layout
sitemesh
back-stack
gridcontrol
yui-compressor
android-screen-support
orchardcms-1.7
multipage
postgresql-performance
gcj
coredump
xmlspy
iphone-web-app
revisions
modelstate
dbal
compiler-specific
ugc
django-notification
document-conversion

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