0

Hi I'm new in symfony.

I'm trying to generate entities from an existing database with doctrine. When I run this command:

php bin/console doctrine:mapping:import --force AppBundle xml

I get this exception :

[Doctrine\ORM\Mapping\MappingException]
Property "shop" in "Bug" was already declared, but it must be declared only once

I have tried to search other solutions, but I didn't find anythings. How can I solve this problem?

This is how mysql workbench creates my table:

CREATE TABLE IF NOT EXISTS `db`.`bug` (
`id_bug` INT(11) NOT NULL AUTO_INCREMENT,
`bug_name` VARCHAR(200) NOT NULL,
`comment` VARCHAR(1000) NOT NULL,
`status` INT(11) NOT NULL DEFAULT '0',
`customer_id` VARCHAR(255) CHARACTER SET 'utf8' NOT NULL,
`shop_id` VARCHAR(255) CHARACTER SET 'utf8' NOT NULL,
`admin_id` VARCHAR(255) CHARACTER SET 'utf8' NOT NULL,
 PRIMARY KEY (`id_bug`),
 INDEX `fk_bug_customer1_idx1` (`customer_id` ASC),
 INDEX `fk_bug_shop1_idx` (`shop_id` ASC),
 INDEX `fk_bug_admin1_idx1` (`admin_id` ASC),
 CONSTRAINT `fk_bug_customer1`
 FOREIGN KEY (`customer_id`)
 REFERENCES `db`.`customer` (`id`)
 ON DELETE NO ACTION
 ON UPDATE NO ACTION,
 CONSTRAINT `fk_bug_shop1`
 FOREIGN KEY (`shop_id`)
 REFERENCES `db`.`shop` (`id`)
 ON DELETE NO ACTION
 ON UPDATE NO ACTION,
 CONSTRAINT `fk_bug_admin1`
 FOREIGN KEY (`admin_id`)
 REFERENCES `db`.`admin` (`id`)
 ON DELETE NO ACTION
 ON UPDATE NO ACTION)
 ENGINE = InnoDB
 DEFAULT CHARACTER SET = latin1;

I'm working in symfony 3.3, mysql and php7.

Thanks.

Cœur
  • 37,241
  • 25
  • 195
  • 267

1 Answers1

0

There were two problem:

  1. First of all there was a relaction duplicated on the same enitity
  2. It was not the only problem. We noticed that in doctrine occours problems when there is a primary key that is also a foreign key, so we added a new field id for the primary key.