> ## Documentation Index
> Fetch the complete documentation index at: https://docs.activeviam.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Add managed objects

> How to add custom managed objects to Atoti Limits persistence by creating JPA entities and repositories, configuring an EntityManager, and registering the entity package via Spring configuration

# Overview

You can set up Atoti Limits to manage custom objects with same `EntityManager` as the [out-of-the-box objects](../../persistence/configuring-persistence#managed-objects). Here’s how to do it:

## 1. Create the Entity

Define the entity class that will be managed by the `EntityManager`. This class should
be annotated with `@Entity` and `@Table` to be recognized as a JPA entity.
For example, the entity may look as follows:

```java theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
package com.activeviam.limits.model.custom.jpa;

@Entity
@Table(name = "my_custom_entity")
public class MyCustomEntity {

  @Id
  @Column(name = "id")
  protected String id;

  @Column(name = "name")
  protected String name;

}
```

## 2. Create a JPA repository

Create the `JpaRepository` for the entity. This could be as simple as:

```java theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
public interface MyCustomJpaRepo extends JpaRepository<MyCustomEntity, String> {

}
```

## 3. Import the JPA repository

Create and import a Spring configuration class that imports the `JpaRepository` for the
entity and uses the same `EntityManager` as the default managed objects, for example:

```java theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
@EnableJpaRepositories(
    entityManagerFactoryRef = LimitsJpaConfig.LIMITS_ENTITY_MANAGER_FACTORY,
    transactionManagerRef = LimitsJpaConfig.LIMITS_TRANSACTION_MANAGER,
    basePackageClasses = {
        MyCustomJpaRepo.class,
    })
public class MyCustomJpaConfig {

}
```

## 4. Scan for the entity

In order to be managed by the same entity manager as the out-of-the-box objects, the entity package
must be added to the list of packages picked up by the `limits.data.jpa.repository.packages-to-scan`
configuration property. The default value for this property is `com.activeviam.limits.model.jpa`, so
in the case of `MyCustomEntity` above, the new property would be:

```yaml theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
limits:
  data:
    jpa:
      repository:
        packages-to-scan: com.activeviam.limits.model.jpa, com.activeviam.limits.model.custom.jpa
```
