gpt4 book ai didi

mysql - 如何在hibernate中将一个实体类映射到具有相同sql模式的四个表?

转载 作者:行者123 更新时间:2023-11-29 20:37:22 25 4
gpt4 key购买 nike

I have four tables with the same sql schema

user_1
+------+--------+----------------------+
| code | name | pass |
+------+--------+----------------------+
| 1 | rajiv | 12345 |
+------+--------+----------------------+

user_2
+------+--------+----------------------+
| code | name | pass |
+------+--------+----------------------+
| 1 | rajiv1 | 12345 |
+------+--------+----------------------+

user_3
+------+--------+----------------------+
| code | name | pass |
+------+--------+----------------------+
| 1 | raji2 | 12345 |
+------+--------+----------------------+


user_4
+------+--------+----------------------+
| code | name | pass |
+------+--------+----------------------+
| 1 | raji3 | 12345 |
+------+--------+----------------------+

I dont want to make 4 entity class for these table

Is there any way so that i can define only one Entity class and map all four tables to that entity so that i can fetch data from whichever table i want to

最佳答案

如果您的数据库支持 View ,我建议创建一个包含所有四个表中的数据的 View ,并将该 View 映射到一个实体。这可能比尝试将 4 个表映射到一个实体更简单、更清晰。

关于mysql - 如何在hibernate中将一个实体类映射到具有相同sql模式的四个表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38736089/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com