Re: JPQL
Greg Young <[email protected]>
| Newsgroups | gmane.comp.programming.domain-driven-design |
|---|---|
| Message-ID | <CAC9RQtj+Q1SUUO-6B+m8xT37Hj5QjivbXiWwHHRUQGhaKizSYA@mail.gmail.com> |
Normally I would try to keep this out of the model.
Generally I would make domain specific querying on the repository (eg
GetCustomersByFirstName). an interface may look like:
GetCustomersByFirstName
GetCusomersBy...
GetCustomerBy...
Then I would compose a more general repository in the implementation of
this repository (using something like JPQL)
List<Customer> GetCustomersByFirstName(string name) {
_composedRepository.......
}
This helps to lower the coupling between the model and the storage. However
there are many times when it can be pragmatic to allow the query language
to come through into the domain.
Another aspect of the conversation to consider is that it is almost always
your GetXXX methods that cause issues here. This is one reason many have
looked at CQRS is to avoid the queries going through the domain model at
all as very often your aggregates don't match up well with the queries you
want to be able to make.
Cheers,
Greg
On Mon, Jul 15, 2013 at 9:15 AM, Tom Eugelink <[email protected]> wrote:
> **
>
>
>
> Hmmm, just finished the chapter on Repositories in IDDD.
>
> Repositories should be set up domain centric (as opposed to DAO which are
> considered table centric). Given that I would drop the option to switch
> Repository implementation to NoSQL databases, but settle on JPA supported
> storage, would it be allowed to have JPQL (or by extention QueryDSL on
> JPQL) slide into the domain? JPQL is a domain centric query language.
>
> Tom
>
>
>
--
Le doute n'est pas une condition agréable, mais la certitude est absurde.