更新使用 JOIN 创建的域对象

发布于 2024-11-03 21:34:09 字数 231 浏览 8 评论 0原文

这种情况通常如何处理?我有一个域对象,其中包含两个表之间联接的结果数据;更新应该如何处理?

一种方法是使用 TableADao、TableBDao(1 对 1 表-Dao 关系)并使用 Repository 类构造域对象,该类可有效处理关系(连接和批量更新)。

有更好的办法吗?使用 JOIN 似乎更有效。这两个表非常小,但是是我必须支持的遗留数据库的一部分。无法改变。

ORM 如何处理这种情况?

How is this situation typically handled? I have a domain object which contains data which is the result of a join between 2 tables; how should the update be handled?

One approach is to have TableADao, TableBDao (1to1 table-Dao relationship) and have the domain object constructed by a Repository class which effectively handles the relationship (join & batch update).

Is there a better way? Using a JOIN seems way more efficient. The 2 tables are very small, but are part of a legacy DB i must support & cannot change.

How do ORM's handle this scenario?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

剧终人散尽 2024-11-10 21:34:09

创建一个视图,您可以更新它,就像它是一个表一样。

Create a view and you can update that as if it were one table.

源来凯始玺欢你 2024-11-10 21:34:09

这取决于您使用的 ORM。它可能支持也可能不支持聚合对象和/或映射视图。

It depends on the ORM you are using. It may or may not support aggregate objects and/or mapped views.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文