DDD, domain entities/VO and JPA

前端 未结 2 1036
隐瞒了意图╮
隐瞒了意图╮ 2020-12-29 06:35

I\'m starting with DDD and you can image my brain is boiling.

My question is related to my domain objects (entities, VO, ...) which represents my domain concepts/log

2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-29 07:06

    I can't see the link you've posted and I have never apply Domain driven design to the Java world. Theoretically what you need is Customer aggregate in the domain layer. In your domain layer there's space for the repository (intended as interface), so you'll have ICustomerRepository. Probably you will have the four prototype for the common persistence issues:

    GetById(CustomerId id);
    Add(Customer c);
    Delete(Customer c);
    Update(Customer c);
    

    In the infrastructure layer you will provide the body (for instance CustomerRepository), in the infrastracture layer you can couple yourself with something technological (for example JPA).

    Domain layer MUST be completly unaware of technology used in the infrastructure. Doing so you could change completly the implementation details having (almost) no troubles.

提交回复
热议问题