> For the complete documentation index, see [llms.txt](https://bxorm.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bxorm.ortusbooks.com/bxorm-2.x/getting-started/configuration/custom-hibernate-config.md).

# Custom Hibernate Config

Pass raw Hibernate settings with a properties file or an inline struct

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:

```js
this.ormSettings = {
    // ...
    ormconfig : "./config/hibernate.properties"
};
```

The file is a simple list of `key=value` pairs, one Hibernate property per line:

```properties
# hibernate.properties
hibernate.use_sql_comments=true
hibernate.jdbc.batch_size=25
```

{% hint style="warning" %}
Only the flat `key=value` properties file format is supported. The XML `hibernate.cfg.xml` format is not yet implemented.
{% endhint %}

## 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:

```js
this.ormSettings = {
    // ...
    hibernateProperties = {
        "hibernate.use_sql_comments" = "true",
        "hibernate.jdbc.batch_size" = "25"
    }
};
```

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:

1. `ormconfig` (the file) is applied first.
2. `hibernateProperties` (the inline struct) is applied second, so it wins on a conflicting key.

{% hint style="info" %}
A few settings that bx-orm needs to work are re-applied internally *after* `ormconfig` and `hibernateProperties`. You cannot override them:

* the JDBC connection provider
* the connection handling mode
* the classloaders
* the session context class
* identifier quoting (use the `quoteIdentifiers` setting)
  {% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://bxorm.ortusbooks.com/bxorm-2.x/getting-started/configuration/custom-hibernate-config.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
