Hibernate 配置文件可以有两种格式,一种是 hibernate.properties ,另一种是
hibernate.cfg.xml
后者稍微方便一些,当增加 hbm 映射文件的时候,可以直接在 hibernate.cfg.xml
里面增加,不必像 hibernate.properties 必须在初始化代码中加入。
但不管怎么说,两种的配置项都是一样的,下面详细介绍:
在 Hibernate 的 src 目录下有一个 hibernate.properties 模板,我们不必自己
从头写,修改模板就可以了:)
hibernate.query.substitutions true 1, false 0, yes 'Y', no 'N'
这个配置意思是当你在 Hibernate 里面输入 true 的时候,Hibernate 会转化为 1 插
入数据库,当你在 Hibernate 里面输入 false 的时候,Hibernate 会转化为 0 插入数据库,
后面的 Y,N 同理。
对于某些数据库,例如 Oracle 来说,没有 boolean 数据类型,就是采用 1 代表
true,0 代表 false,因此使用这个配置在 Hibernate 里面直接用 true/false 会非常直
观。
hibernate.dialect net.sf.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class com.mysql.jdbc.Driver
hibernate.connection.url jdbc:mysql:///test
hibernate.connection.username root
hibernate.connection.password
这是一个连接 MySQL 数据库的例子,很直观,不必解释,不同的数据库的连接参数模板
中全部给出了。
hibernate.connection.pool_size 1
hibernate.statement_cache.size 25
评论0
最新资源