Hibernate Union 替代方案

编程入门 行业动态 更新时间:2024-10-26 16:22:43
本文介绍了Hibernate Union 替代方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

使用休眠实现联合查询有哪些替代方法?我知道 hibernate 目前不支持联合查询,现在我看到的唯一方法是使用视图表.

What alternatives do I have to implement a union query using hibernate? I know hibernate does not support union queries at the moment, right now the only way I see to make a union is to use a view table.

另一种选择是使用普通的 jdbc,但这样我会丢失所有示例/标准查询的好处,以及 hibernate 对表/列执行的 hibernate 映射验证.

The other option is to use plain jdbc, but this way I would loose all my example/criteria queries goodies, as well as the hibernate mapping validation that hibernate performs against the tables/columns.

推荐答案

使用 VIEW.可以使用实体名称将相同的类映射到不同的表/视图,因此您甚至不会有太多重复.在那里,这样做,工作正常.

Use VIEW. The same classes can be mapped to different tables/views using entity name, so you won't even have much of a duplication. Being there, done that, works OK.

Plain JDBC 还有一个隐藏的问题:它不知道 Hibernate 会话缓存,所以如果某些东西被缓存到事务结束并且没有从 Hibernate 会话中刷新,JDBC 查询将找不到它.有时可能会很令人费解.

Plain JDBC has another hidden problem: it's unaware of Hibernate session cache, so if something got cached till the end of the transaction and not flushed from Hibernate session, JDBC query won't find it. Could be very puzzling sometimes.

更多推荐

Hibernate Union 替代方案

本文发布于:2023-07-30 14:18:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1250207.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方案   Hibernate   Union

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!