Custom Hibernate Config
Sometimes bx-orm doesn't have a dedicated setting for a Hibernate property you need. There are two ways to set arbitrary Hibernate properties directly: a hibernate.properties file via ormconfig, or an inline struct via hibernateProperties.
ormConfig: A Properties File
Point ormconfig at a flat, standard Java hibernate.properties-formatted file:
this.ormSettings = {
// ...
ormconfig : "./config/hibernate.properties"
};The file is a simple list of key=value pairs, one Hibernate property per line:
# hibernate.properties
hibernate.connection.release_mode=on_close
hibernate.use_sql_comments=trueOnly the flat key=value properties file format is supported. The XML hibernate.cfg.xml format is not yet implemented.
hibernateProperties: An Inline Struct
For settings you'd rather keep alongside the rest of your ORM config instead of in a separate file, use the hibernateProperties struct:
this.ormSettings = {
// ...
hibernateProperties = {
"hibernate.connection.release_mode" = "on_close",
"hibernate.use_sql_comments" = "true"
}
};Every entry is applied directly to the Hibernate configuration, giving you an escape hatch for tuning any Hibernate setting bx-orm doesn't expose a dedicated setting for.
Precedence
Both settings are applied after bx-orm's own internal defaults, so either can override bx-orm's hardcoded Hibernate settings (e.g. flush and auto-close behavior). When using both together:
ormconfig(the file) is applied first.hibernateProperties(the inline struct) is applied second, so it wins on a conflicting key.
Example: Fixing Cross-Database "Statement Is Closed" Errors
If your app runs against multiple database engines (e.g. MySQL, MSSQL, PostgreSQL) you may see Hibernate "statement is closed" errors on MSSQL or Postgres, caused by stale JDBC statements after per-save transaction commits. Setting hibernate.connection.release_mode per-app resolves this:
Last updated
Was this helpful?