hibernate - hibernate配置文件中的session-factory标签?

标签 hibernate hibernate-mapping hibernate-criteria sessionfactory

我是新的 Hibernate 学习者。 我很困惑,为什么我们在 hibernate 配置文件中使用标签 session-factory

我们还在主类中使用它来为所有事务创建 session 工厂对象。

最佳答案

在 hibernate 状态下 SessionFactory用于管理数据库的 session 和事务,如 documentation 中所示。 :

The main contract here is the creation of Session instances. Usually an application has a single SessionFactory instance and threads servicing client requests obtain Session instances from this factory.

The internal state of a SessionFactory is immutable. Once it is created this internal state is set. This internal state includes all of the metadata about Object/Relational Mapping.

编辑:

<session factory> XML配置文件中的标签用于配置初始化 hibernate 的 session 工厂设置,例如Dialect类和连接 Driver类属性,您可以在 Hibernate - Configuration 中查看XML 配置文件必须符合 Hibernate 3 配置 DTD

sessionFactory我们在类中使用的实例用于管理每个数据库事务的 session ,您可以在 jBossDeveloper's Sessions and transactions tutorial 中找到有关它的更多详细信息。 .

关于hibernate - hibernate配置文件中的session-factory标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30697659/

相关文章:

java - 在这种情况下如何使用 DISTINCT 创建 hibernate 条件

mysql - 减少日志记录实体的写入操作数量

java - JPA 2.1 具有函数的列的索引注释

mysql - 如何在 Hibernate 中为每个公司创建一个 customerNumber 生成器

java - hibernate criteria group查询错误

mysql - 我无法在阔叶中使用 em.merge 存储实体

hibernate - 在 Xml 映射中使用 Hibernate 设置创建和更新时间

hibernate - Unable to instantiate custom type error in Hibernate mapping 枚举映射

hibernate - 如何在没有时间的情况下使用createCriteria比较日期

java - 使用限制的 Hibernate Criteria