ddd-repositories

Is it ok for entities to access repositories?

混江龙づ霸主 提交于 2019-11-26 15:26:15
I've just started working with DDD, so maybe this is a silly question... Is it ok for an entity to access a repository (via some IRepository interface) to get a value at runtime? For example, I want to enforce a "default" selection for a property: class Person { private Company _employer; public Company Employer { get { return _employer; } set { if(value != null) { _employer = value; } else { _employer = employerRepository.GetDefaultEmployer(); } } } ... } My question is whehter doing something like this is a horrible violation of DDD principles. And if it isn't, my next question would be what

How are Spring Data repositories actually implemented?

只愿长相守 提交于 2019-11-26 10:09:22
I have been working with Spring Data JPA repository in my project for some time and I know the below points: In the repository interfaces, we can add the methods like findByCustomerNameAndPhone() (assuming customerName and phone are fields in the domain object). Then, Spring provides the implementation by implementing the above repository interface methods at runtime (during the application run). I am interested on how this has been coded and I have looked at the Spring JPA source code & APIs, but I could not find answers to the questions below: How is the repository implementation class

How are Spring Data repositories actually implemented?

假如想象 提交于 2019-11-26 01:49:08
问题 I have been working with Spring Data JPA repository in my project for some time and I know the below points: In the repository interfaces, we can add the methods like findByCustomerNameAndPhone() (assuming customerName and phone are fields in the domain object). Then, Spring provides the implementation by implementing the above repository interface methods at runtime (during the application run). I am interested on how this has been coded and I have looked at the Spring JPA source code & APIs

What's an Aggregate Root?

跟風遠走 提交于 2019-11-25 22:40:32
问题 I\'m trying to get my head around how to properly use the repository pattern. The central concept of an Aggregate Root keeps coming up. When searching both the web and Stack Overflow for help with what an aggregate root is, I keep finding discussions about them and dead links to pages that are supposed to contain base definitions. In the context of the repository pattern, what is an aggregate root? 回答1: In the context of the repository pattern, aggregate roots are the only objects your client