Use @ORM alias optionally #5923

Closed
opened 2026-01-22 15:22:08 +01:00 by admin · 1 comment
Owner

Originally created by @javiertrejo on GitHub (Mar 15, 2018).

Originally assigned to: @Ocramius on GitHub.

It's a good idea use the alias @ORM as an optional parameter configuration when run the cli command to generate the Entities.

Using Doctrine Stand alone the @ORM causes a MappingException

For Example:

First i run the cli command to generate the entities:

./sbin/doctrine orm:convert-mapping --extend 'Itsg\Core\Base\AbstractObject' --namespace 'App\Personal\Entity\' --force --from-database annotation opt/

This is an example of a generated entity:

use Doctrine\ORM\Mapping as ORM;

/**
 * DfForms
 *
 * @ORM\Table(name="df_forms", uniqueConstraints={@ORM\UniqueConstraint(name="dff_name", columns={"dff_name"})})
 * @ORM\Entity
 */

When i try to get the default repository i have an error:

MappingException
Class "App\Personal\Entity\DfForms" sub class of "Itsg\Core\Base\AbstractObject" is not a valid entity or mapped super class.

The problem solves if i remove the @ORM alias from use line and annotations lines.

Originally created by @javiertrejo on GitHub (Mar 15, 2018). Originally assigned to: @Ocramius on GitHub. It's a good idea use the alias @ORM as an optional parameter configuration when run the cli command to generate the Entities. Using Doctrine Stand alone the @ORM causes a MappingException For Example: First i run the cli command to generate the entities: `./sbin/doctrine orm:convert-mapping --extend 'Itsg\Core\Base\AbstractObject' --namespace 'App\Personal\Entity\' --force --from-database annotation opt/` This is an example of a generated entity: ``` use Doctrine\ORM\Mapping as ORM; /** * DfForms * * @ORM\Table(name="df_forms", uniqueConstraints={@ORM\UniqueConstraint(name="dff_name", columns={"dff_name"})}) * @ORM\Entity */ ``` When i try to get the default repository i have an error: _MappingException Class "App\Personal\Entity\DfForms" sub class of "Itsg\Core\Base\AbstractObject" is not a valid entity or mapped super class._ The problem solves if i remove the @ORM alias from use line and annotations lines.
admin added the ImprovementWon't FixQuestion labels 2026-01-22 15:22:08 +01:00
admin closed this issue 2026-01-22 15:22:08 +01:00
Author
Owner

@Ocramius commented on GitHub (Mar 15, 2018):

the cli command to generate the Entities.

We've deprecated and removed the entity generator in the next major: no more improvements will be applied.

The problem solves if i remove the @ORM alias from use line and annotations lines.

This is because you have two different annotation drivers there, of which one is configured with a simplified annotation reader. We're removing that one too, so you should always import your annotations.

@Ocramius commented on GitHub (Mar 15, 2018): > the cli command to generate the Entities. We've deprecated and removed the entity generator in the next major: no more improvements will be applied. > The problem solves if i remove the `@ORM` alias from use line and annotations lines. This is because you have two different annotation drivers there, of which one is configured with a simplified annotation reader. We're removing that one too, so you should always import your annotations.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5923