domain-driven-design

Aggregate to JPA Entity mapping

喜夏-厌秋 提交于 2020-06-28 04:08:27
问题 In a DDD -project I'm contributing to, we're seeking for some convenient solutions to map entity objects to domain objects and visa versa. Developers of this project agreed to fully decouple domain model from data model. The data layer uses JPA (Hibernate) as persistence technology. As we all reckon that persistence is an implementation detail in DDD, from a developers' point of view we're all seeking for the most appropriate solution in every aspect of the application. The biggest concern we

Aggregate to JPA Entity mapping

泪湿孤枕 提交于 2020-06-28 04:08:10
问题 In a DDD -project I'm contributing to, we're seeking for some convenient solutions to map entity objects to domain objects and visa versa. Developers of this project agreed to fully decouple domain model from data model. The data layer uses JPA (Hibernate) as persistence technology. As we all reckon that persistence is an implementation detail in DDD, from a developers' point of view we're all seeking for the most appropriate solution in every aspect of the application. The biggest concern we

Entity Framework Core 2.1 - owned types and nested value objects

笑着哭i 提交于 2020-06-23 07:23:32
问题 I'm learning DDD and the tutorial I'm currently following is implemented using NHibernate, but since my lack of experience with it I've decided to go through the course using EF Core 2.1. However, I'm currently a bit stuck with the following: I have three classes Customer which is an entity and two value objects ( CustomerStatus and inside of it value object ExpirationDate ) - like this: public class Customer : Entity { //... constructor, other properties and behavior omitted for the sake of

Does everything have to be an aggregate? Many-to-Many Link

一笑奈何 提交于 2020-06-01 05:50:15
问题 Say I have two entities Notifications and Users. I want to mark that a user has seen a specific notification. This would commonly be done with a many-to-many relationship e.g. UserNotification Because there is no invariant around this relationship (we don't care if "all" users have seen the notification) these users shouldn't be on the notification aggregate. On the opposite side, the users aggregate doesn't need a list of notifications on it So that leads to say that the UserNotification

Is it a good practice to use JPA entities as domain models?

我的未来我决定 提交于 2020-05-25 04:15:45
问题 or to create a domain layer that is consisted of domain models and talk to JPA entities for database accessing? What are the pros and cons for both approaches ? Thanks! 回答1: This does really depend on how you code your domain. In general (in Java) I prefer create a separate set of JPA annotated DTOs to work with persistence. Such DTOs will match db table and will be used within a custom repository that will expose to clients a semantic API will run queries against such DTOs will use factories

Is it a good practice to use JPA entities as domain models?

自作多情 提交于 2020-05-25 04:15:12
问题 or to create a domain layer that is consisted of domain models and talk to JPA entities for database accessing? What are the pros and cons for both approaches ? Thanks! 回答1: This does really depend on how you code your domain. In general (in Java) I prefer create a separate set of JPA annotated DTOs to work with persistence. Such DTOs will match db table and will be used within a custom repository that will expose to clients a semantic API will run queries against such DTOs will use factories

Many-to-many relationships in DDD

时光总嘲笑我的痴心妄想 提交于 2020-05-24 10:43:29
问题 I'm new to DDD and I'm stuck with many-to-many relationships. E.g. we have two aggregate roots - Tasks and Workers. Contract is definitely not aggregate root, because it has no sense without Task and Worker. So, it should be part of some aggregate. But which aggregate should it belong to? We need to know both summary costs of all task contracts and summary costs of all worker contracts. And it's natural for me to have contracts collection both in Task and in Worker. Well, I can move Costs

Many-to-many relationships in DDD

℡╲_俬逩灬. 提交于 2020-05-24 10:40:52
问题 I'm new to DDD and I'm stuck with many-to-many relationships. E.g. we have two aggregate roots - Tasks and Workers. Contract is definitely not aggregate root, because it has no sense without Task and Worker. So, it should be part of some aggregate. But which aggregate should it belong to? We need to know both summary costs of all task contracts and summary costs of all worker contracts. And it's natural for me to have contracts collection both in Task and in Worker. Well, I can move Costs

Returning Domain Objects from Repositories on Joining tables

元气小坏坏 提交于 2020-04-30 11:22:21
问题 I have been reading that Repositories should return domain objects only. I am having difficulty with implementing this. I currently have API with Service Layer, Repository and I am using EF Core to access sql database. If we consider User(Id, Name, address, PhoneNumber, Email, Username) and Orders (id, OrderDetails, UserId) as 2 domain objects. One Customer can have multiple Orders. I have created navigation property public virtual User User{ get; set; } and foreign Key. Service layer needs

How entities covered with in an aggregate Root are saved in DDD?

别说谁变了你拦得住时间么 提交于 2020-03-25 18:54:13
问题 After reading lot of posts, I realised if an aggregate root exists for a concept/context, we need to have a single repository for that whole concept/context. If thats the case, I see there won't be any repositories for the internal entities. If so, how these internal entities are saved to database? I have a many internal entities under the aggregate root. So, wondering If I need to have all the saving of the internal entities under the aggregate root repository, it's going to be bloated.