> For the complete documentation index, see [llms.txt](https://coldbox-orm.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://coldbox-orm.ortusbooks.com/v5.x/base-orm-service/service-methods/criteria-queries/getrestrictions.md).

# getRestrictions

Get the restrictions builder that prepares conditions for a criteria's add(), or(), and() and not()

Get the restrictions builder. Its methods (`isEq`, `like`, `between`, `isNull`, `or`, `and`, `not`, ...) build conditions **without adding them** to a criteria, so you can pass them to a criteria's `add()`, `or()`, `and()` and `not()`. It is the same object as a criteria's `c.restrictions`. See [Restrictions](/v5.x/criteria-queries/criteria-builder/restrictions.md).

## Returns

* The bx-orm criteria restrictions builder

## Arguments

| Key        | Type   | Required | Default | Description                                                                                                                                                                                                                                                                           |
| ---------- | ------ | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| entityName | string | false    | ""      | The entity to take the restrictions from. Any mapped entity works, since restrictions are not tied to an entity: they are resolved against the criteria they are added to. When empty, the first mapped entity is used. Not available on a Virtual Entity Service or an Active Entity |

If the application has no ORM entities, a `BaseORMService.NoEntitiesFound` error is thrown.

## Examples

```javascript
var r = ormService.getRestrictions();

var users = ormService
    .newCriteria( "User" )
    .or( r.isEq( "lastName", "Majano" ), r.isGt( "createdDate", dateAdd( "d", -7, now() ) ) )
    .list();

// Nested groups
var users = ormService
    .newCriteria( "User" )
    .add( r.or( r.isEq( "role.slug", "admin" ), r.and( r.isTrue( "isActive" ), r.not( r.isNull( "lastLogin" ) ) ) ) )
    .list();

// Virtual entity service
var r = userService.getRestrictions();
```

{% hint style="info" %}
**Changes from cborm 5**: `getRestrictions()` used to return `cborm.models.criterion.Restrictions`, a proxy to Hibernate's `org.hibernate.criterion.Restrictions`, which Hibernate 7 removed. It now returns the bx-orm restrictions builder, and methods it doesn't have are no longer proxied to Hibernate. The Adobe ColdFusion reserved-word workarounds (`$and()`, `$or()`) are no longer needed, although they still work.
{% 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://coldbox-orm.ortusbooks.com/v5.x/base-orm-service/service-methods/criteria-queries/getrestrictions.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.
