> 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/reference/built-in-functions.md).

# Built-in Functions

bx-orm ships a set of Built-in Functions (BIFs) for working with entities and the underlying Hibernate session. They fall into two groups:

## Entity Functions

| Function                                                                    | Description                                                                         |
| --------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| [EntityDelete](/reference/built-in-functions/entitydelete.md)               | Delete an entity from the database.                                                 |
| [EntityIsAttached](/reference/built-in-functions/entityisattached.md)       | Check whether an entity is attached to the current ORM session.                     |
| [EntityLoad](/reference/built-in-functions/entityload.md)                   | Load an entity or array of entities from the database.                              |
| [EntityLoadByExample](/reference/built-in-functions/entityloadbyexample.md) | Load entities matching an example entity.                                           |
| [EntityLoadByPK](/reference/built-in-functions/entityloadbypk.md)           | Load an array of entities by the primary key.                                       |
| [EntityMerge](/reference/built-in-functions/entitymerge.md)                 | Merge the state of the given entity into the current persistence context (session). |
| [EntityNameArray](/reference/built-in-functions/entitynamearray.md)         | Retrieve an array of entity names for this ORM application.                         |
| [EntityNameList](/reference/built-in-functions/entitynamelist.md)           | Retrieve a list of entity names for this ORM application.                           |
| [EntityNew](/reference/built-in-functions/entitynew.md)                     | Instantiate a new entity, optionally with a struct of properties.                   |
| [EntityReload](/reference/built-in-functions/entityreload.md)               | Reload an entity from the database.                                                 |
| [EntitySave](/reference/built-in-functions/entitysave.md)                   | Save the provided entity to the persistence context.                                |
| [EntityToQuery](/reference/built-in-functions/entitytoquery.md)             | Convert an entity or array of entities to a Query object.                           |

## ORM Session Functions

| Function                                                                          | Description                                                                                      |
| --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| [ORMClearSession](/reference/built-in-functions/ormclearsession.md)               | Clear the Hibernate session for the current context and provided (or default) datasource.        |
| [ORMCloseAllSessions](/reference/built-in-functions/ormcloseallsessions.md)       | Close all Hibernate sessions for the current context on all datasources.                         |
| [ORMCloseSession](/reference/built-in-functions/ormclosesession.md)               | Close the Hibernate session for the current context and provided (or default) datasource.        |
| [ORMEvictCollection](/reference/built-in-functions/ormevictcollection.md)         | Evict all entity data for a given collection on a given entity type from the second-level cache. |
| [ORMEvictEntity](/reference/built-in-functions/ormevictentity.md)                 | Evict all entity data for this entity name from the second-level cache.                          |
| [ORMEvictQueries](/reference/built-in-functions/ormevictqueries.md)               | Evict all queries from the named or default cache on the named or default datasource.            |
| [ORMExecuteQuery](/reference/built-in-functions/ormexecutequery.md)               | Execute an HQL query with (optional) parameters and specific query options.                      |
| [ORMFlush](/reference/built-in-functions/ormflush.md)                             | Flush the Hibernate session, synchronizing the in-memory state with the database.                |
| [ORMFlushAll](/reference/built-in-functions/ormflushall.md)                       | Flush all open Hibernate sessions in the current request.                                        |
| [ORMGetHibernateVersion](/reference/built-in-functions/ormgethibernateversion.md) | Retrieve the installed Hibernate version.                                                        |
| [ORMGetSession](/reference/built-in-functions/ormgetsession.md)                   | Retrieve the Hibernate Session configured for this datasource or default datasource.             |
| [ORMGetSessionFactory](/reference/built-in-functions/ormgetsessionfactory.md)     | Retrieve the Hibernate SessionFactory configured for this datasource or default datasource.      |
| [ORMReload](/reference/built-in-functions/ormreload.md)                           | Reload the ORM application.                                                                      |


---

# 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/reference/built-in-functions.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.
