`
iwebcode
  • 浏览: 2023662 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
文章分类
社区版块
存档分类
最新评论

Hibernate 配置属性

 
阅读更多

Hibernate 配置属性

属性名 用途
hibernate.dialect 允许 Hibernate 针对特定的关系数据库生成优化的 SQL 的org.hibernate.dialect.Dialect的类名。

例如:full.classname.of.Dialect

在大多数情况下,Hibernate 可以根据 JDBC 驱动返回的JDBC metadata选择正确的org.hibernate.dialect.Dialect实现。

hibernate.show_sql 输出所有 SQL 语句到控制台。有一个另外的选择是把org.hibernate.SQL这个 log category设为debug

例如:true|false

hibernate.format_sql 在 log 和 console 中打印出更漂亮的 SQL。

例如:true|false

hibernate.default_schema 在生成的 SQL 中,将给定的 schema/tablespace 附加于非全限定名的表名上。

例如:SCHEMA_NAME

hibernate.default_catalog 在生成的 SQL 中,将给定的 catalog 附加于非全限定名的表名上。

例如:CATALOG_NAME

hibernate.session_factory_name org.hibernate.SessionFactory创建后,将自动使用这个名字绑定到 JNDI 中。

例如:jndi/composite/name

hibernate.max_fetch_depth 为单向关联(一对一,多对一)的外连接抓取(outer join fetch)树设置最大深度。值为0意味着将关闭默认的外连接抓取。

例如:建议在03之间取值

hibernate.default_batch_fetch_size 为 Hibernate 关联的批量抓取设置默认数量。

例如:建议的取值为48,和16

hibernate.default_entity_mode 为由这个SessionFactory打开的所有 Session 指定默认的实体表现模式。

取值dynamic-mapdom4jpojo

hibernate.order_updates 强制 Hibernate 按照被更新数据的主键,为 SQL 更新排序。这么做将减少在高并发系统中事务的死锁。

例如:true|false

hibernate.generate_statistics 如果开启,Hibernate 将收集有助于性能调节的统计数据。

例如:true|false

hibernate.use_identifier_rollback 如果开启,在对象被删除时生成的标识属性将被重设为默认值。

例如:true|false

hibernate.use_sql_comments 如果开启,Hibernate 将在 SQL 中生成有助于调试的注释信息,默认值为false

例如:true|false


表3.4.Hibernate JDBC 和连接(connection)属性

属性名 用途
hibernate.jdbc.fetch_size 非零值,指定 JDBC 抓取数量的大小(调用Statement.setFetchSize())。
hibernate.jdbc.batch_size 非零值,允许 Hibernate 使用 JDBC2 的批量更新。

例如:建议取530之间的值

hibernate.jdbc.batch_versioned_data Set this property totrueif your JDBC driver returns correct row counts fromexecuteBatch(). It is usually safe to turn this option on. Hibernate will then use batched DML for automatically versioned data. Defaults tofalse.

例如:true|false

hibernate.jdbc.factory_class 选择一个自定义的Batcher。多数应用程序不需要这个配置属性。

例如:classname.of.Batcher

hibernate.jdbc.use_scrollable_resultset 允许 Hibernate 使用 JDBC2 的可滚动结果集。只有在使用用户提供的 JDBC 连接时,这个选项才是必要的,否则 Hibernate 会使用连接的元数据。

例如:true|false

hibernate.jdbc.use_streams_for_binary 在 JDBC 读写binaryserializable的类型时使用流(stream)(系统级属性)。

例如:true|false

hibernate.jdbc.use_get_generated_keys 在数据插入数据库之后,允许使用 JDBC3PreparedStatement.getGeneratedKeys()来获取数据库生成的 key(键)。需要 JDBC3+ 驱动和 JRE1.4+,如果你的数据库驱动在使用 Hibernate 的标识生成器时遇到问题,请将此值设为 false。默认情况下将使用连接的元数据来判定驱动的能力。

例如:true | false

hibernate.connection.provider_class 自定义ConnectionProvider的类名,此类用来向 Hibernate 提供 JDBC 连接。

例如:classname.of.ConnectionProvider

hibernate.connection.isolation 设置 JDBC 事务隔离级别。查看java.sql.Connection来了解各个值的具体意义,但请注意多数数据库都不支持所有的隔离级别。

例如:1, 2, 4, 8

hibernate.connection.autocommit 允许被缓存的 JDBC 连接开启自动提交(autocommit)(不推荐)。

例如:true|false

hibernate.connection.release_mode 指定 Hibernate 在何时释放 JDBC 连接。默认情况下,直到 Session 被显式关闭或被断开连接时,才会释放 JDBC 连接。对于应用程序服务器的 JTA 数据源,你应当使用after_statement,这样在每次 JDBC 调用后,都会主动的释放连接。对于非 JTA 的连接,使用after_transaction在每个事务结束时释放连接是合理的。auto将为 JTA 和 CMT 事务策略选择after_statement,为JDBC事务策略选择after_transaction

例如:auto(默认) |on_close|after_transaction|after_statement

This setting only affectsSessions returned fromSessionFactory.openSession. ForSessions obtained throughSessionFactory.getCurrentSession, theCurrentSessionContextimplementation configured for use controls the connection release mode for thoseSessions. See第2.5节 “上下文相关的会话(Contextual Session)”

hibernate.connection.<propertyName> 把 JDBC 属性<propertyName>传递给DriverManager.getConnection()
hibernate.jndi.<propertyName> <propertyName>属性传递给 JNDIInitialContextFactory

表3.5.Hibernate 缓存属性

属性名 用途
hibernate.cache.provider_class 自定义的CacheProvider的类名。

例如:classname.of.CacheProvider

hibernate.cache.use_minimal_puts 以频繁的读操作为代价,优化二级缓存来最小化写操作。在 Hibernate3 中,这个设置对的集群缓存非常有用,对集群缓存的实现而言,默认是开启的。

例如:true | false

hibernate.cache.use_query_cache 允许查询缓存,个别查询仍然需要被设置为可缓存的。

例如:true | false

hibernate.cache.use_second_level_cache 能用来完全禁止使用二级缓存。对那些在类的映射定义中指定<cache>的类,会默认开启二级缓存。

例如:true | false

hibernate.cache.query_cache_factory 自定义实现QueryCache接口的类名,默认为内建的StandardQueryCache

例如:classname.of.QueryCache

hibernate.cache.region_prefix 二级缓存区域名的前缀。

例如:prefix

hibernate.cache.use_structured_entries 强制 Hibernate 以更人性化的格式将数据存入二级缓存。

例如:true | false


表3.6.Hibernate 事务属性

属性名 用途
hibernate.transaction.factory_class 一个TransactionFactory的类名,用于 HibernateTransactionAPI(默认为JDBCTransactionFactory)。

例如:classname.of.TransactionFactory

jta.UserTransaction 一个 JNDI 名字,被JTATransactionFactory用来从应用服务器获取 JTAUserTransaction

例如:jndi/composite/name

hibernate.transaction.manager_lookup_class 一个TransactionManagerLookup的类名 — 当使用 JVM 级缓存,或在 JTA 环境中使用 hilo 生成器的时候需要该类。

例如:classname.of.TransactionManagerLookup

hibernate.transaction.flush_before_completion If enabled, the session will be automatically flushed during the before completion phase of the transaction. Built-in and automatic session context management is preferred, see第2.5节 “上下文相关的会话(Contextual Session)”.

例如:true|false

hibernate.transaction.auto_close_session If enabled, the session will be automatically closed during the after completion phase of the transaction. Built-in and automatic session context management is preferred, see第2.5节 “上下文相关的会话(Contextual Session)”.

例如:true|false


表3.7.其他属性

属性名 用途
hibernate.current_session_context_class Supply a custom strategy for the scoping of the "current"Session. See第2.5节 “上下文相关的会话(Contextual Session)”for more information about the built-in strategies.

例如:jta|thread|managed|custom.Class

hibernate.query.factory_class 选择 HQL 解析器的实现。

例如:org.hibernate.hql.ast.ASTQueryTranslatorFactory
org.hibernate.hql.classic.ClassicQueryTranslatorFactory

hibernate.query.substitutions 将 Hibernate 查询中的符号映射到 SQL 查询中的符号(符号可能是函数名或常量名字)。

例如:hqlLiteral=SQL_LITERAL, hqlFunction=SQLFUNC

hibernate.hbm2ddl.auto SessionFactory创建时,自动检查数据库结构,或者将数据库 schema 的 DDL 导出到数据库。使用create-drop时,在显式关闭SessionFactory时,将删除掉数据库 schema。

例如:validate|update|create|create-drop

hibernate.bytecode.use_reflection_optimizer

Enables the use of bytecode manipulation instead of runtime reflection. This is a System-level property and cannot be set inhibernate.cfg.xml. Reflection can sometimes be useful when troubleshooting. Hibernate always requires either CGLIB or javassist even if you turn off the optimizer.

例如:true|false

hibernate.bytecode.provider

Both javassist or cglib can be used as byte manipulation engines; the default isjavassist.

e.g.javassist|cglib


分享到:
评论

相关推荐

    hibernate配置属性参数[定义].pdf

    hibernate配置属性参数[定义].pdf

    hibernate 配置属性参数详情(全)

    ssh整合时 对hibernate的性能参数配置必看

    Hibernate+中文文档

    3.3. Hibernate配置属性 3.4. Hibernate JDBC和连接(connection)属性 3.5. Hibernate缓存属性 3.6. Hibernate事务属性 3.7. 其他属性 3.8. Hibernate SQL方言 (hibernate.dialect) 3.9. Hibernate日志类别 ...

    hibernate3.2中文文档(chm格式)

    3.3. Hibernate配置属性 3.4. Hibernate JDBC和连接(connection)属性 3.5. Hibernate缓存属性 3.6. Hibernate事务属性 3.7. 其他属性 3.8. Hibernate SQL方言 (hibernate.dialect) 3.9. Hibernate日志类别 ...

    HibernateAPI中文版.chm

    3.3. Hibernate配置属性 3.4. Hibernate JDBC和连接(connection)属性 3.5. Hibernate缓存属性 3.6. Hibernate事务属性 3.7. 其他属性 3.8. Hibernate SQL方言 (hibernate.dialect) 3.9. Hibernate日志类别 ...

    Hibernate_3.2.0_符合Java习惯的关系数据库持久化

    3.3. Hibernate配置属性 3.4. Hibernate JDBC和连接(connection)属性 3.5. Hibernate缓存属性 3.6. Hibernate事务属性 3.7. 其他属性 3.8. Hibernate SQL方言 (hibernate.dialect) 3.9. Hibernate日志类别 ...

    Hibernate配置各种数据源详解

    Hibernate配置各种数据源 &lt;hibernate-configuration&gt; &lt;!– 各属性的配置–&gt; &lt;!—为true表示将Hibernate发送给数据库的sql显示出来 –&gt; ”show_sql”&gt;true &lt;!– SQL方言,这边设定的是MySQL –&gt; ”dialect”&gt;...

    Hibernate映射配置详解

    Hibernate映射配置详解

    经典hibernate配置详解

    hibernate配置的详细说明!有各个元素属性的详细说明,比较适合初学者!

    Hibernate配置

    详细讲述了Hibernate的配置知识,以及配置属性的说明.

    让hibernate输出sql语句参数配置.doc

    hibernate.use_identifer_rollback 参数用于如果开启,在对象被删除时生成的标识属性将被重设为默认值。其取值为 true 或 false。 13. hibernate.use_sql_comments hibernate.use_sql_comments 参数用于如果开启,...

    Hibernate 参数设置一览表 属性名 用途

    Hibernate 参数设置一览表 属性名 用途 详细解读hibernate配置时的参数定义

    hibernate配置

    --Hibernate配置的根节点--&gt; &lt;session-factory&gt; &lt;!--配置SessionFactory--&gt; &lt;property name="dialect"&gt;org.hibernate.dialect.Oracle9Dialect&lt;/property&gt; &lt;!--数据库方言(数据库类型)--&gt; ...

    hibernate.cfg.xml中配置信息详解

    该文件中包含了多个配置属性,用于控制 Hibernate 的各种功能和特性。本文将对 Hibernate.cfg.xml 中的配置信息进行详细的解释和分析。 hibernate.dialect Hibernate.dialect 属性用于指定 Hibernate 的数据库 ...

    hibernate3

    Hibernate应用通过Configuration实例来指定对象--关系映射文件的位置或者动态配置Hibernate的属性,然后创建SessionFactory实例。 (2)SessionFactory:初始化Hibernate,充当数据存储源的代理,创建Session对象。...

    hibernate.hbm2ddl.auto属性详解

    详解hibernate.hbm2ddl.atuo 属性的配置

    Hibernate 高级配置

    Hibernate高级配置 1. Hibernate与触发器协同工作 1)、触发器使session的缓存中的数据与数据库中的数据不一致 2)、session的update()方法盲目的激发触发器 2. Hibernate中的createQuery方法 1)、uniqueResult()...

    深入浅出Hibernate中文版 part1

    3.2 Hibernate配置 3.3 日志配置 3.4 第一段代码 3.5 代码初解 第4章 Hibernate基础 4.1 Hibernate基础语义 4.2 基础配置 4.3 Hibernate O/R映射 4.4 数据关联 4.5 Hibernate数据检索 4.6 HQL实用技术 ...

    Hibernate不同数据库的连接及SQL方言

    在Hibernate的配置文件中,我们可以使用元素来设置数据库连接的各种属性,例如驱动程序的类名、连接URL、用户名、密码等。以SQL Server为例,我们可以使用以下配置: &lt;property name="connection.driver_class"&gt;...

Global site tag (gtag.js) - Google Analytics