gorm


In grails 2 when using multiple datasources, can I specify which datasource a criteria should use?


In my grails 2 application I have multiple datasources configured in Datasources.groovy. My domain class mappings specify that all datasources should be used
class Book {
static mapping = { datasource 'ALL' }
For basic Gorm calls I am able to specify which datasource to use.
Book.lookup.save() correctly uses the 'lookup' datasource
Is there a way to specify which datasource a criteria should use?
I have tried the following 4 solutions without any luck
def c = Book.lookup.createCriteria(); c.list{...
The call to .list throws: java.sql.SQLException: Connection is closed
def c = Book.createCriteria(); c.lookup.list{...
no such method
Injecting the datasource
def dataSource_lookup
...
Book.createCriteria(dataSource_lookup)
no such method
Specifying that the whole service where the criteria is located should use a specific datasource doesn't seem to be working for the criteria nor for the basic save() call. I'm running grails 2.1.0.
static datasource = 'lookup'
Not a great solution, however it does work if you access the datasource beforehand (presumably within the same hibernate session).
Book.lookup.read(1)
def c = Book.lookup.createCriteria()
c.list{...

Related Links

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)?
use of mappedBy in Many to Many relationship in Grails
Domain class auto validation in grails

Categories

HOME
arduino-uno
atom-editor
google-api-php-client
appx
lodash
react-router
gis
google-oauth
analysis
survey
ckeditor
adobe-analytics
n-gram
usergrid
zebra-printers
quickfix
uitypeeditor
facebook-page
evopdf
lldb
reverse-proxy
php-openssl
crosstab
shopware
dynamic-featured-image
tooltipster
entitlements
filezilla
applozic
xacml
opentype
large-file-upload
windows-server-2000
google-cloud-endpoints-v2
data-manipulation
ioio
karaf
gtrendsr
rotational-matrices
space-complexity
neuroscience
optix
eclipse-scout
pdf-reactor
glew
fakeiteasy
unixodbc
netcdf4
wptoolkit
react-scripts
dotnetzip
drupal-6
darcs
libusb-win32
media-player
sqldf
webdriverjs
redundancy
or-tools
pycaffe
migradoc
infix-notation
android-textview
multi-level
jwplayer7
pagedlist
qgraphicsview
design-by-contract
freedesktop.org
qdialog
atk4
map-projections
census
clipperlib
bigbluebutton
camanjs
tt-news
cdt
terminfo
xojo
funcunit
phpthumb
poller
floating-point-precision
mysqltuner
ruby-datamapper
back-stack
referrer
mhtml
propertyeditor
automount
multipage
twrequest
objective-c-2.0
windows-phone-7.1.1
fireworks
mod-auth
datareader
sproutcore-2
nerddinner
sector
ubuntu-9.04
post-build
ntvdm.exe

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