《Hibernate3的配置参数汇总》由会员分享,可在线阅读,更多相关《Hibernate3的配置参数汇总(7页珍藏版)》请在金锄头文库上搜索。
1、Hibernate3Hibernate3 的配置参数汇总的配置参数汇总SQLSQL 方言方言 1 1、HibernateHibernate JDBCJDBC 属性属性hibernate.connection.driver_classhibernate.connection.driver_class jdbcjdbc 驱动类驱动类 hibernate.connection.urlhibernate.connection.url jdbcjdbc URLURL hibernate.connection.usernamehibernate.connection.username 数据库用户数据库用户
2、 hibernate.connection.passwordhibernate.connection.password 数据库用户密码数据库用户密码 hibernate.connection.pool_sizehibernate.connection.pool_size 连接池容量上限数目连接池容量上限数目注:使用注:使用 C3P0C3P0 的的 propertiesproperties 样例代码:样例代码:hibernate.connection.driver_classhibernate.connection.driver_class = = org.postgresql.Driveror
3、g.postgresql.Driver hibernate.connection.urlhibernate.connection.url = = jdbc:postgresql:/localhost/mydatabasejdbc:postgresql:/localhost/mydatabase hibernate.connection.usernamehibernate.connection.username = = myusermyuser hibernate.connection.passwordhibernate.connection.password = = secretsecret
4、hibernate.c3p0.min_size=5hibernate.c3p0.min_size=5 hibernate.c3p0.max_size=20hibernate.c3p0.max_size=20 hibernate.c3p0.timeout=1800hibernate.c3p0.timeout=1800 hibernate.c3p0.max_statements=50hibernate.c3p0.max_statements=50 hibernate.dialecthibernate.dialect = = org.hibernate.dialect.PostgreSQLDiale
5、ctorg.hibernate.dialect.PostgreSQLDialect2 2、HibernateHibernate 的数据源属性的数据源属性hibernate.connection.datasourcehibernate.connection.datasource 数据源数据源 JNDIJNDI 名字名字 hibernate.jndi.urlhibernate.jndi.url JNDIJNDI 提供者的提供者的 URLURL ( (可选可选) ) hibernate.jndi.classhibernate.jndi.class JNDIJNDI InitialContextFac
6、toryInitialContextFactory 类类 ( (可选可选) ) hibernate.connection.usernamehibernate.connection.username 数据库用户数据库用户 ( (可选可选) ) hibernate.connection.passwordhibernate.connection.password 数据库用户密码数据库用户密码 ( (可选可选) )注:应用程序服务器注:应用程序服务器 JNDIJNDI 数据源的数据源的 hibernate.propertieshibernate.properties 样例代码:样例代码:hiberna
7、te.connection.datasourcehibernate.connection.datasource = = java:/comp/env/jdbc/testjava:/comp/env/jdbc/test hibernate.transaction.factory_classhibernate.transaction.factory_class = = org.hibernate.transaction.JTATransactionFactoryorg.hibernate.transaction.JTATransactionFactory hibernate.transaction
8、.manager_lookup_classhibernate.transaction.manager_lookup_class = = org.hibernate.transaction.JBossTransactionManagerLookuporg.hibernate.transaction.JBossTransactionManagerLookup hibernate.dialecthibernate.dialect = = org.hibernate.dialect.PostgreSQLDialectorg.hibernate.dialect.PostgreSQLDialect3 3、
9、HibernateHibernate 配置属性(可选)配置属性(可选)hibernate.dialecthibernate.dialect 一个一个 HibernateHibernate DialectDialect 类名允许类名允许 HibernateHibernate 针对特定的关系数据库生成优化的针对特定的关系数据库生成优化的 SQL.SQL.取值取值 full.classname.of.Dialectfull.classname.of.Dialect hibernate.show_sqlhibernate.show_sql 输出所有输出所有 SQLSQL 语句到控制句到控制台. .取值
10、取值 truetrue | | falsefalsehibernate.format_sqlhibernate.format_sql 在在 loglog 和和 consoleconsole 中打印出更漂亮的中打印出更漂亮的 sql.sql.取值取值 truetrue | | falsefalsehibernate.default_schemahibernate.default_schema 在生成的在生成的 SQLSQL 中中, , 将给定的将给定的 schema/tablespaceschema/tablespace 附加于非全限定名的表名上附加于非全限定名的表名上. .取值取值 SCHEM
11、A_NAMESCHEMA_NAMEhibernate.default_cataloghibernate.default_catalog 在生成的在生成的 SQLSQL 中中, , 将给定的将给定的 catalogcatalog 附加于没全限定名的表名上附加于没全限定名的表名上. .取值取值 CATALOG_NAMECATALOG_NAMEhibernate.session_factory_namehibernate.session_factory_name SessionFactorySessionFactory 创建后,将自动使用这个名字绑定到创建后,将自动使用这个名字绑定到 JNDIJND
12、I 中中. .取值取值 jndi/composite/namejndi/composite/namehibernate.max_fetch_depthhibernate.max_fetch_depth 为单向关联为单向关联( (一对一一对一, , 多对一多对一) )的外连接抓取(的外连接抓取(outerouter joinjoin fetchfetch)树设置最大深度)树设置最大深度. . 值为值为 0 0 意味着将关闭默认的外连接抓取意味着将关闭默认的外连接抓取. .取值取值 建议在建议在 0 0 到到 3 3 之间取值之间取值hibernate.default_batch_fetch_si
13、zehibernate.default_batch_fetch_size 为为 HibernateHibernate 关联的批量抓取设置默认数量关联的批量抓取设置默认数量. .取值取值 建议的取值为建议的取值为 4,4, 8,8, 和和 1616hibernate.default_entity_modehibernate.default_entity_mode 为由这个为由这个 SessionFactorySessionFactory 打开的所有打开的所有 SessionSession 指定默认的实体表现模式指定默认的实体表现模式. .取值取值 dynamic-map,dynamic-map,
14、 dom4j,dom4j, pojopojohibernate.order_updateshibernate.order_updates 强制强制 HibernateHibernate 按照被更新数据的主键,为按照被更新数据的主键,为 SQLSQL 更新排序。这么做将减少在高并发系统中事务的死锁。取值更新排序。这么做将减少在高并发系统中事务的死锁。取值 truetrue | | falsefalsehibernate.generate_statisticshibernate.generate_statistics 如果开启如果开启, , HibernateHibernate 将收集有助于性能调
15、节的统计数据将收集有助于性能调节的统计数据. .取值取值 truetrue | | falsefalsehibernate.use_identifer_rollbackhibernate.use_identifer_rollback 如果开启如果开启, , 在对象被删除时生成的标识属性将被重设为默认值在对象被删除时生成的标识属性将被重设为默认值. .取值取值 truetrue | | falsefalsehibernate.use_sql_commentshibernate.use_sql_comments 如果开启如果开启, , HibernateHibernate 将在将在 SQLSQL 中生成有助于调试的注释信息中生成有助于调试的注释信息, , 默认值为默认值为 false.false.取值取值 truetrue | | falsefalse4 4、HibernateHibernate JDBCJDBC 和连接和连接(connection)(connection)属性属性hibernate.jdbc.fetch_sizehibe