Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions docs/src/docs/asciidoc/multipleDataSources/dataServices.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

GORM Data Services can operate on multiple data sources.

The `@Transactional` annotation can specify the `DataSource` where `ZipCode` domains exists.

When no annotation is used, then the service goes to the default `DataSource`, as in `deleteByCode(String code)`.

[source,groovy]
----
@CompileStatic
@Service(ZipCode)
interface ZipCodeService {

@Transactional('lookup')
ZipCode findByCode(String code)

void deleteByCode(String code)
}
----
8 changes: 8 additions & 0 deletions docs/src/docs/asciidoc/multipleDataSources/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@ for(ConnectionSource<SessionFactory, HibernateConnectionSourceSettings> connecti
SessionFactory sessionFactory = connectionSource.source
}
----

=== Data Services with Multiple Data Sources

include::dataServices.adoc[]

=== Queries with Multiple Data Sources

include::queries.adoc[]
23 changes: 23 additions & 0 deletions docs/src/docs/asciidoc/multipleDataSources/queries.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

Queries can be written for mulitiple data sources with a dynamic finder, where query, or criteria query as well.

Where Query:

[source,groovy]
----
ZipCode.where {}.withConnection('lookup').list()
----

Dynamic Finder:

[source,groovy]
----
ZipCode.lookup.findAll()
----

Criteria:

[source,groovy]
----
ZipCode.lookup.createCriteria.list {}
----