> 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/newcriteria.md).

# newCriteria

Get a new criteria builder (a bx-orm entityCriteria()) bound to an entity

Get a brand new criteria builder to build and run criteria queries with. In cborm 6 it is a bx-orm criteria builder, the same object `entityCriteria( entityName )` returns. See [Criteria Builder](/v5.x/criteria-queries/criteria-builder/getting-started.md).

## Returns

* The bx-orm criteria builder for the entity (`entityCriteria()`)

## Arguments

| Key              | Type    | Required | Default                | Description                                                                                               |
| ---------------- | ------- | -------- | ---------------------- | --------------------------------------------------------------------------------------------------------- |
| entityName       | string  | true     | ---                    | The entity name to bind the criteria query to. Not passed on a Virtual Entity Service or an Active Entity |
| useQueryCaching  | boolean | false    | false                  | Cache the results of the criteria's queries in the second-level query cache                               |
| queryCacheRegion | string  | false    | criterias.{entityName} | The query cache region to use when `useQueryCaching` is true                                              |
| datasource       | string  | false    | The service datasource | Ignored: the criteria runs on the entity's own datasource                                                 |

## Examples

```javascript
var users = ormService
    .newCriteria( entityName = "User" )
    .isGt( "age", 30 )
    .isTrue( "isActive" )
    .list( max = 30, offset = 10, sortOrder = "lastName" );

// Virtual entity service or Active Entity: no entity name
var admins = userService.newCriteria().isEq( "role.slug", "admin" ).list();

// With query caching in the default region criterias.User
var active = ormService.newCriteria( "User", true ).isTrue( "isActive" ).list();
```

{% hint style="info" %}
**Changes from cborm 5**: `newCriteria()` used to return `cborm.models.criterion.CriteriaBuilder`, a wrapper around the Hibernate Criteria API that Hibernate 7 removed. It now returns the bx-orm criteria builder, which keeps the cborm method names. Values no longer need `idCast()` or `autoCast()`.
{% 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/newcriteria.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.
