Hibernate 配置属性
来源:互联网 发布:海南网络广播 编辑:程序博客网 时间:2024/04/26 21:54
有大量属性能用来控制 Hibernate 在运行期的行为。它们都是可选的,并拥有适当的默认值。
警告
其中一些属性是"系统级(system-level)的"。系统级属性只能通过java -Dproperty=value
或hibernate.properties
来设置,而不能用上面描述的其他方法来设置。
Hibernate 配置属性
org.hibernate.dialect.Dialect
的类名。例如:full.classname.of.Dialect
在大多数情况下,Hibernate 可以根据 JDBC 驱动返回的 JDBC metadata
选择正确的 org.hibernate.dialect.Dialect
实现。
org.hibernate.SQL
这个 log category设为 debug
。例如:true
| false
例如:true
| false
例如:SCHEMA_NAME
例如:CATALOG_NAME
org.hibernate.SessionFactory
创建后,将自动使用这个名字绑定到 JNDI 中。例如:jndi/composite/name
0
意味着将关闭默认的外连接抓取。例如: 建议在 0
到 3
之间取值
例如:建议的取值为 4
,8
,和 16
SessionFactory
打开的所有 Session 指定默认的实体表现模式。取值dynamic-map
,dom4j
,pojo
例如:true
| false
例如:true
|false
例如:true
| false
false
。例如:true
| false
Hibernate JDBC 和连接(connection)属性
Statement.setFetchSize()
)。hibernate.jdbc.batch_size非零值,允许 Hibernate 使用 JDBC2 的批量更新。 例如:建议取 5
到 30
之间的值
true
if your JDBC driver returns correct row counts from executeBatch()
. It is usually safe to turn this option on. Hibernate will then use batched DML for automatically versioned data. Defaults to false
.例如:true
| false
Batcher
。多数应用程序不需要这个配置属性。例如:classname.of.Batcher
例如:true
| false
binary
或 serializable
的类型时使用流(stream)(系统级属性)。例如:true
| false
PreparedStatement.getGeneratedKeys()
来获取数据库生成的 key(键)。需要 JDBC3+ 驱动和 JRE1.4+,如果你的数据库驱动在使用 Hibernate 的标识生成器时遇到问题,请将此值设为 false。默认情况下将使用连接的元数据来判定驱动的能力。例如:true | false
ConnectionProvider
的类名,此类用来向 Hibernate 提供 JDBC 连接。例如:classname.of.ConnectionProvider
java.sql.Connection
来了解各个值的具体意义,但请注意多数数据库都不支持所有的隔离级别。例如:1, 2, 4, 8
例如:true
| false
after_statement
,这样在每次 JDBC 调用后,都会主动的释放连接。对于非 JTA 的连接,使用after_transaction
在每个事务结束时释放连接是合理的。auto
将为 JTA 和 CMT 事务策略选择 after_statement
,为JDBC事务策略选择after_transaction
。例如:auto
(默认) | on_close
| after_transaction
|after_statement
This setting only affects Session
s returned fromSessionFactory.openSession
. For Session
s obtained through SessionFactory.getCurrentSession
, theCurrentSessionContext
implementation configured for use controls the connection release mode for those Session
s. See 第 2.5 节 “上下文相关的会话(Contextual Session)”
DriverManager.getConnection()
。hibernate.jndi.<propertyName>把 <propertyName> 属性传递给 JNDI InitialContextFactory
。
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
Hibernate 事务属性
hibernate.transaction.factory_class
一个 TransactionFactory
的类名,用于 HibernateTransaction
API(默认为 JDBCTransactionFactory
)。例如:classname.of.TransactionFactory
jta.UserTransaction
一个 JNDI 名字,被 JTATransactionFactory
用来从应用服务器获取 JTA UserTransaction
。例如: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
其他属性
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 in hibernate.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 is javassist
.
e.g. javassist
| cglib
- Hibernate配置属性
- Hibernate配置属性
- hibernate各种属性配置
- Hibernate 配置属性
- hibernate属性配置
- Hibernate配置属性详解
- Hibernate配置属性详解
- Hibernate 配置属性
- Hibernate 配置属性
- Hibernate 配置属性
- Hibernate配置属性
- Hibernate 配置属性
- Hibernate配置属性参数
- Hibernate配置属性
- Hibernate常用配置属性
- hibernate 属性配置
- hibernate属性配置
- Hibernate 配置 属性 -
- CSDN 总结
- 想干的人永远在找方法,不想干的人永远在找理由;世界上没有走不通的路,只有想不通的人
- Uncaught SyntaxError: Unexpected token <
- 10个为设计者准备的HTML5在线工具
- checkstyle安装及使用
- Hibernate 配置属性
- C - 笔记
- 算法导论学习笔记(1)---堆排序
- 云邮件服务商Mailjet里程碑事件:迎来10亿邮件处理量
- 如何无限增大在线压力?
- SharePoint 2007中所有的Event Handlers事件清单
- 分享25个优秀的 HTML5 开发教程
- 各种浏览器清除缓存的方法。
- android项目加入混淆器打包失败