# Doctrine Mapping

If any Objectiphy mapping values are not set, Objectiphy will use Doctrine's definitions instead. This is the case even if some attributes are supplied and others are not. For example, if you specify an Objectiphy `Column` attribute or annotation with just a `name` attribute, Objectiphy will also check the Doctrine attributes or annotations for information on data type and relationships. If you don't want it to do that, just specify all of the mapping definition values in the Objectiphy syntax (or set the column name to 'IGNORE' on the Objectiphy mapping definition to ignore the property completely).

Not all Doctrine attributes and annotations are supported or used by Objectiphy - only the following ones are processed:

**ORM\Table**

* **name**: *Name of the main table that stores information for this entity.*

**ORM\Column**

* **name**: *Name of the column that stores data for this property.*
* **type**: *Data type name.*

**ORM\Id**

* There are no values for this, but if present, it will be used to identify the primary key. This is the equivalent of `#[Objectiphy\Column(isPrimaryKey: true)]` (attribute) or  `@Objectiphy\Column(isPrimaryKey=true)`(annotation).

**ORM\OrderBy**

* If specified, this just contains an array of properties on the child class to order by for one-to-many and many-to-many relationships, eg. `['name' => 'ASC', 'type' => 'DESC']` (attribute) or  `{"name"="ASC","type"="DESC"}` (annotation).

**ORM\OneToOne**

* **targetEntity**: *Class name of child entity.* \
  If not in the same namespace as the parent entity, it is best to fully qualify the class name.&#x20;
* **mappedBy**: *Property of child class which owns the relationship, if applicable.* \
  Only necessary if the child owns the relationship (ie. the primary key of the table for the parent class is stored in a column on the table for the child class).&#x20;
* **fetch**: *LAZY or EAGER*
* **cascade**: *REMOVE or ALL* \
  Whether to delete child objects if the parent is deleted.&#x20;
* **orphanRemoval**: *true or false* \
  Whether to delete child objects if they are removed from their parent.

**ORM\ManyToOne**

* **targetEntity**: *Class name of child entity.*&#x20;
* **mappedBy**: *Property of child class which owns the relationship, if applicable.* \
  Only necessary if the child owns the relationship (ie. the primary key of the table for the parent class is stored in a column on the table for the child class).&#x20;
* **fetch**: *LAZY or EAGER*
* **cascade**: *REMOVE or ALL* \
  Whether to delete child objects if the parent is deleted.&#x20;
* **orphanRemoval**: *true or false* \
  Whether to delete child objects if they are removed from their parent.

**ORM\OneToMany**

* **targetEntity**: *Class name of child entity.*&#x20;
* **fetch**: *LAZY or EAGER*
* **cascade**: *REMOVE or ALL* \
  Whether to delete child objects if the parent is deleted.&#x20;
* **orphanRemoval**: *true or false* \
  Whether to delete child objects if they are removed from their parent.

**ORM\ManyToMany**

* **targetEntity**: *Class name of child entity.*&#x20;
* **cascade**: *REMOVE or ALL* \
  Whether to delete child objects if the parent is deleted.&#x20;
* **orphanRemoval**: *true or false* \
  Whether to delete child objects if they are removed from their parent.

**ORM\JoinColumn**

* **name**: *Name of column on local table that holds the foreign key.*
* **referencedColumnName**: *Name of column on target table that holds the key.*\
  Defaults to id if not specified.

**ORM\Embedded**

* **class**: *Fully qualified class name of the value object to embed.*
* **columnPrefix**: *Prefix applied to all column names, or false if not using a prefix.*


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.objectiphy.net/annotations/doctrine-annotations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
