Reputation: 51
Sorry for my English (gg translation). I just passed all my entities with attributes instead of annotations. Everything was working before and now I have this error. I can't get it up. Do you have an idea ? Thanks
composer.json :
Symfony 6.1.*
"php": ">=8.0.2",
"doctrine/annotations": "^1.13",
"doctrine/doctrine-bundle": "^2.6",
"doctrine/doctrine-migrations-bundle": "^3.2",
"doctrine/orm": "^2.12",
doctrine.yaml
doctrine:
dbal:
url: '%env(resolve:DATABASE_URL)%'
# IMPORTANT: You MUST configure your server version,
# either here or in the DATABASE_URL env var (see .env file)
#server_version: '13'
orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
App:
is_bundle: false
#type: annotation
type: attribute
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
dql:
numeric_functions:
acos: DoctrineExtensions\Query\Mysql\Acos
cos: DoctrineExtensions\Query\Mysql\Cos
radians: DoctrineExtensions\Query\Mysql\Radians
sin: DoctrineExtensions\Query\Mysql\Sin
error message : "Attribute "Doctrine\ORM\Mapping\Table" must not be repeated"
Upvotes: 2
Views: 1153
Reputation: 160
Same for me: I made the modifications with rector It transformed this code:
* @ORM\Entity(repositoryClass="DropzoneRepository::class")
* @ORM\Table(name="dropzone")
* @ORM\Entity
into:
#[ORM\Table(name: 'dropzone')]
#[ORM\Entity(repositoryClass: DropzoneRepository::class)]
#[ORM\Entity]
The last line must be removed or you get two ORM\Entity annotations:
//#[ORM\Entity]
Upvotes: 1
Reputation: 51
I made the modification of the annotations in attributes with rector.
In one of my entities, he transformed me this code:
/**
* @ORM\Entity(repositoryClass=CodePostalRepository::class)
* @Table(name="code_postal_villes",
* uniqueConstraints={@UniqueConstraint(name="ville_code_postal", columns={"code_postal_id", "villes_id"})}
* )
* @Table(name="code_postal",
* indexes={@Index(name="cp_idx",columns={"cp"})},
* uniqueConstraints={@UniqueConstraint(name="cp", columns={"cp"})}
* )
*/
in :
#[Table(name: 'code_postal_villes')]
#[UniqueConstraint(name: 'ville_code_postal', columns: ['code_postal_id', 'villes_id'])]
#[Table(name: 'code_postal')]
#[Index(name: 'cp_idx', columns: ['cp'])]
#[UniqueConstraint(name: 'cp', columns: ['cp'])]
#[ORM\Entity(repositoryClass: CodePostalRepository::class)]
This is what poses the problem. There cannot be twice the table attribute
It remains to be seen how I solve the problem.
Upvotes: 2