-
Notifications
You must be signed in to change notification settings - Fork 358
Support @MappedCollection map key is embedded #2054
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The key of a mapped collection is completely independent from the id of the parent entity. Do you mean the |
That's right, it means that both idColumn and keyColumn need to have this capability. keyColumn should also be supported in the design. When a child entity of an aggregate root uses a map, the key is always the id of the other aggregate root. If the ID of the aggregate root referenced by the ID is a composite ID, then it means that the key of the map should also be a composite ID (embedded). |
That is wrong. The key is always the key of the |
Maybe it's something wrong with my description or I've abused this feature. Let me give you a simple example. This is expected. record GoodsId(
int type, String code
) {
}
record Goods(
@Id @Embedded.Nullable GoodsId id,
String name
) {
}
record Order(
@Id long id,
@MappedCollection(idColumn = "order_id", keyColumn = "type+code") Map<GoodsId, OrderItem> itemMap
) {
}
record OrderItem(
@Embedded.Empty GoodsId id,
int quantity
) {
} After this, I will try AI translation, hoping to reduce errors in expression. |
Oh, I see. You want to use the id of an entity as the key in a Map. Interesting, but valid I guess. |
This is a relevant feature of composite ID.
The key of the Map type should be the composite id (embedded) when the subentity collection references the aggregate root with the composite id.
The text was updated successfully, but these errors were encountered: