---
title: "Session: How to Customize Collection Assignment for Entities"
url: "https://docs.ravendb.net/6.2/client-api/session/configuration/how-to-customize-collection-assignment-for-entities"
version: "6.2"
language: "java"
---

# Session: How to Customize Collection Assignment for Entities

> Client language: Java. Also available for [C#](https://docs.ravendb.net/6.2/client-api/session/configuration/how-to-customize-collection-assignment-for-entities.md), [Python](https://docs.ravendb.net/6.2/client-api/session/configuration/how-to-customize-collection-assignment-for-entities.python.md), [PHP](https://docs.ravendb.net/6.2/client-api/session/configuration/how-to-customize-collection-assignment-for-entities.php.md), [Node.js](https://docs.ravendb.net/6.2/client-api/session/configuration/how-to-customize-collection-assignment-for-entities.nodejs.md).
>
> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

Entities are grouped into [collections](https://docs.ravendb.net/6.2/client-api/faq/what-is-a-collection.md) on the server side. In order to determine the collection name that an entity belongs to
there is special convention which return the collection name based on the type of an entity: [`findCollectionName`](https://docs.ravendb.net/6.2/client-api/configuration/identifier-generation/global.java.md#findcollectionname).

## Example

By default a collection name is pluralized form of a name of an entity type. For example objects of type `Category` will belong to `Categories` collection. However if your intention
is to classify them as `ProductGroups` use the following code:

```java
store.getConventions().setFindCollectionName(clazz -> {
  if (Category.class.isAssignableFrom(clazz)) {
      return "ProductGroups";
  }

  return DocumentConventions.defaultGetCollectionName(clazz);
});
```

This can become very useful when there is a need to deal with [polymorphic data](https://docs.ravendb.net/6.2/indexes/indexing-polymorphic-data.java.md).

## See also

- [Conventions](https://docs.ravendb.net/6.2/client-api/configuration/conventions.md)
- [How to Customize ID Generation for Entities](https://docs.ravendb.net/6.2/client-api/session/configuration/how-to-customize-id-generation-for-entities.md)
- [How to Customize the Identity Property Lookup for Entities](https://docs.ravendb.net/6.2/client-api/session/configuration/how-to-customize-identity-property-lookup-for-entities.java.md)
- [What is a Collection?](https://docs.ravendb.net/6.2/client-api/faq/what-is-a-collection.md)
