Hibernate JDBC属性
属性名 用途
hibernate.connection.driver_class jdbc驱动类
hibernate.connection.url jdbc URL
hibernate.connection.username 数据库用户
hibernate.connection.password 数据库用户密码
hibernate.connection.pool_size 连接池容量上限数目
例如:
Hibernate数据源属性
属性名 用途
hibernate.connection.datasource 数据源JNDI名字
hibernate.jndi.url URL of the JNDI provider (optional)
hibernate.jndi.class class of the JNDI InitialContextFactory(optional)
hibernate.connection.username database user (optional)
hibernate.connection.password database user password (optional)
Hibernate可选配置
属性名 用途
hibernate.dialect 方言,指Hibernate该使用哪种数据库语言,
例如: full.classname.of.Dialect(Hibernate默认会根据返回的JDBC驱动来判断)
hibernate.show_sql 是否在控制台显示执行的语句,例如:true/false
hibernate.format_sql 是否格式化控制台显示的语句,例如:true/false
hibernate.default_schema 给定不合格的数据库名,如果给定的数据库名错误,则默认使用这个名称
hibernate.default_catalog 给定不合格的表名生成SQL语句,如上;
hibernate.session_factory_name 绑定的JNDI的名称
hibernate.generate_statistics 如果开启,Hibernate将收集统计,对性能优化非常有用,例如:true/false
hibernate.use_sql_comments 如果开启,Hibernate会生成SQL语句的注释,易于调试,例如:true/false
Hibernate 与 JDBC连接属性(Connetion)
属性名 用途
hibernate.connection.autocommit 自动提交JDBC池,提交执行的SQL。(不建议),默认为false
Hibernate缓存属性(Cache)
属性名 用途
hibernate.cache.provider_class 指定缓存产品的厂商,例如:org.hibernate.cache.EhCacheProvider
hibernate.cache.use_query_cache 启用查询缓存,个人查询最好开启,例如:true/false
hibernate.cache.use_second_level_cache 启用或禁止是否使用二级缓存,例如:true/false
Hibernate事务属性
属性名 用途
hibernate.hbm2ddl.auto 自动创建|更新|验证数据库表结构,
例如:(validate | update | create | create-drop)
validate 加载hibernate时,验证创建数据库表结构
create 每次加载hibernate,重新创建数据库表结构,会导致数据库数据丢失。
create-drop 加载hibernate时创建,会话时删除表结构
update 加载hibernate自动更新数据库结构
Hibernate SQL方言 (hibernate.dialect)
数据库 方言
DB2 org.hibernate.dialect.DB2Dialect
PostgreSQL org.hibernate.dialect.PostgreSQLDialect
MySQL org.hibernate.dialect.MySQLDialect
Oracle 9i org.hibernate.dialect.Oracle9iDialect
Oracle 10g org.hibernate.dialect.Oracle10gDialect
Microsoft SQL Server org.hibernate.dialect.SQLServerDialect