Re: JPQL
Rickard Öberg <[email protected]>
| Newsgroups | gmane.comp.programming.domain-driven-design |
|---|---|
| Message-ID | <[email protected]> |
On 7/15/13 14:35 , Greg Young wrote:
> 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.
Not to mention that you get issues if you start using these methods to
build views, as they are rarely designed to handle things like paging
and sorting, and such view-related things.
/Rickard
------------------------------------