数据库持久性¶
监视器扩展能够通过 Hibernate 类库。
备注
为了利用hibernate持久性,hibernate扩展必须安装在核心监视扩展的顶部。见 安装监视器扩展 有关详细信息。
配置¶
一般¶
为了激活hibernate持久性 storage
参数必须设置为值“hibernate”:
storage=hibernate
hibernate存储后端支持 history
和 live
但是,在启用 live
模式,因为它在请求的整个生命周期内导致与数据库的许多事务。除非需要实时更新数据库,否则 history
建议使用模式。
数据库¶
文件 db.properties
在 <GEOSERVER_DATA_DIR>/monitoring
目录指定Hibernate数据库。默认情况下,位于 monitoring
使用目录。可以通过编辑 db.properties
文件::
# default configuration is for h2
driver=org.h2.Driver
url=jdbc:h2:file:${GEOSERVER_DATA_DIR}/monitoring/monitoring
例如,要将请求数据存储在外部PostgreSQL数据库中,请设置 db.properties
到:
driver=org.postgresql.Driver
url=jdbc:postgresql://192.168.1.124:5432/monitoring
username=bob
password=foobar
defaultAutoCommit=false
除了 db.properties
文件是 hibernate.properties
包含Hibernate自身配置的文件。这个文件的一个重要参数是hibernate方言,它通知hibernate它正在与之交谈的数据库类型。
当更改数据库类型时 databasePlatform
和 database
必须更新参数。例如切换到PostgreSQL::
# hibernate dialect
databasePlatform=org.hibernate.dialect.PostgreSQLDialect
database=POSTGRESQL
# other hibernate configuration
hibernate.use_sql_comments=true
generateDdl=true
hibernate.format_sql=true
showSql=false
hibernate.generate_statistics=true
hibernate.session_factory_name=SessionFactory
hibernate.hbm2ddl.auto=update
hibernate.bytecode.use_reflection_optimizer=true
hibernate.show_sql=false
冬眠¶
如前一节所述 hibernate.properties
文件包含Hibernate本身的配置。除了数据库方言参数外,建议不要更改此文件,除非您是有经验的Hibernate用户。