更新使用 JOIN 创建的域对象
这种情况通常如何处理?我有一个域对象,其中包含两个表之间联接的结果数据;更新应该如何处理?
一种方法是使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
创建一个视图,您可以更新它,就像它是一个表一样。
Create a view and you can update that as if it were one table.
这取决于您使用的 ORM。它可能支持也可能不支持聚合对象和/或映射视图。
It depends on the ORM you are using. It may or may not support aggregate objects and/or mapped views.