The domain layer should not be 'married' to any other layer, but it needs to call CRUD functions in the persistence layer.
The idea of the domain layer not knowing the persistence layer (or any other layer) is to avoid 'marrying' it with a specific implementation of the persistence layer. Understand: make calls, yes, but through interfaces.
The above quote from another concept. The layer below can not make calls at the domain layer. Not by interface, nor by. Who makes the calls, who orchestrates everything is the domain layer.
So the two ideas that you expose are correct, but deal with different things (although they follow the same philosophy of separation of concepts).
Examples: Let's say you have class UsersBL
for business rules and class UsersRepository
for persistence.
The UsersBL
class will need to call the UsersRepository
class for creating, searching, changing the data.
The first concept you mentioned says that the UsersRepository
class can not contain calls to the UsersBL
class. For example, it might seem useful to use a validation function that is already implemented and tested in the UsersBL
class, but that is wrong .
The second concept says that the
UsersBL
class should make calls in the
UsersRepository
class, of course, but should not do this through instances of the
UsersRepository
class. The class in the domain should use interfaces.