gpt4 book ai didi

java - hibernate 动态模型

转载 作者:搜寻专家 更新时间:2023-10-31 20:28:48 24 4
gpt4 key购买 nike

我正在阅读 Hibernate 文档并遇到了 Hibernate 动态模型的概念:Dynamic models

我了解到使用动态模型概念我们不需要单独编写任何 POJO 类,我们只需要编写一个映射文件。实际上我们什么时候会使用这个功能?

文档还说:

One of the main advantages of dynamic mapping is quick turnaround time for prototyping, without the need for entity class implementation. However, you lose compile-time type checking and will likely deal with many exceptions at runtime. As a result of the Hibernate mapping, the database schema can easily be normalized and sound, allowing to add a proper domain model implementation on top later on.

能否请您帮助我理解它的优点,我无法理解它的含义。

文档还说:

Session dynamicSession = pojoSession.getSession(EntityMode.MAP);

Please note that the call to getSession() using an EntityMode is on the Session API, not the SessionFactory. That way, the new Session shares the underlying JDBC connection, transaction, and other context information. This means you do not have to call flush() and close() on the secondary Session, and also leave the transaction and connection handling to the primary unit of work.

在这一点上,我理解 pojoSession 与 Session 对象相同,并且根据声明什么是辅助 Session。

请帮助我理解 Hibernate 3.x 的动态模型概念。

最佳答案

动态模型可用于用户或管理员可以在运行时修改内容模型的任何应用程序。基本上大多数内容管理系统都允许这样做。因此可以将 Hibernate 用作一种内容存储库。

关于java - hibernate 动态模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19504771/

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