简体   繁体   English

静态表的 DDD 聚合根

[英]DDD Aggregate Root for static tables

We are refactoring an existing application using Spring Data JPA.我们正在使用 Spring Data JPA 重构现有应用程序。 There are close to 250 static code database tables which can be referred by other aggregate roots.有近250个静态代码数据库表可以被其他聚合根引用。 In order to attach a code table to an aggregate root, we need to access the particular code table record.为了将代码表附加到聚合根,我们需要访问特定的代码表记录。 Does that mean we should create 250 repositories?这是否意味着我们应该创建 250 个存储库? I mean a repo per static code table since it's an aggregate root itself?我的意思是每个静态代码表的回购,因为它本身就是一个聚合根?

I saw this question, which is kind of similar, but in my case I have a lot of static tables.我看到了这个类似的问题,但就我而言,我有很多静态表。

In the context of [tag:Domain Driven Design], REPOSITORY should be understood as described by Eric Evans in his 2003 book.在 [tag:Domain Driven Design] 的上下文中, REPOSITORY应该理解为 Eric Evans 在他 2003 年的书中所描述的。 The repository pattern is introduced and described in chapter 6, which is about "The Life Cycle of a Domain Object".存储库模式在第 6 章介绍和描述,该章是关于“域对象的生命周期”。

So if your static code tables have life cycles that are managed by your domain model, then yes the should probably be expressed as aggregates with their own repositories.因此,如果您的静态代码表具有由您的域模型管理的生命周期,那么是的,应该将其表示为具有自己的存储库的聚合。

On the other hand, if they are just reference data, then using the repository pattern isn't particularly important.另一方面,如果它们只是参考数据,那么使用存储库模式并不是特别重要。 You'll want some sort of implementation hiding boundary so that your application is insulated from the details of how to access the reference data, but that boundary doesn't particularly need to be a repository .你会需要某种实现隐藏边界,使您的应用程序从如何访问参考数据细节绝缘,但边界并不特别需要一个存储库

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM