学说,如何离开加入未生成的实体?

I have rights:

CREATE TABLE `rights` (
    `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(255) NOT NULL DEFAULT '',
    PRIMARY KEY (`id`),
    UNIQUE INDEX `U_name` (`name`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;

and profiles:

CREATE TABLE `profile` (
    `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(255) NOT NULL DEFAULT '',
    PRIMARY KEY (`id`),
    UNIQUE INDEX `U_name` (`name`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;

I want to connect profiles to rights and also profiles to profiles:

CREATE TABLE `profile_profile` (
    `profile_id1` INT(10) UNSIGNED NOT NULL DEFAULT '0',
    `profile_id2` INT(10) UNSIGNED NOT NULL DEFAULT '0',
    PRIMARY KEY (`profile_id1`, `profile_id2`),
    INDEX `I_profile_id2` (`profile_id2`),
    CONSTRAINT `FK_profile_profile-profile-1` FOREIGN KEY (`profile_id1`) REFERENCES `profile` (`id`) ON UPDATE CASCADE ON DELETE CASCADE,
    CONSTRAINT `FK_profile_profile-profile-2` FOREIGN KEY (`profile_id2`) REFERENCES `profile` (`id`) ON UPDATE CASCADE ON DELETE CASCADE
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;

CREATE TABLE `profile_right` (
    `profile_id` INT(10) UNSIGNED NOT NULL DEFAULT '0',
    `right_id` INT(10) UNSIGNED NOT NULL DEFAULT '0',
    PRIMARY KEY (`profile_id`, `right_id`),
    INDEX `I_right_id` (`right_id`),
    CONSTRAINT `FK_profile_right-profile` FOREIGN KEY (`profile_id`) REFERENCES `profile` (`id`) ON UPDATE CASCADE ON DELETE CASCADE,
    CONSTRAINT `FK_profile_right-rights` FOREIGN KEY (`right_id`) REFERENCES `rights` (`id`) ON UPDATE CASCADE ON DELETE CASCADE
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;

a better overview:enter image description here

so I generate entities:

php apps/doctrine.php dev orm:generate-entities libs/ --no-backup --extend="\Doctrine\Entity\BaseEntity"

here come the problems. The Profile and Rights entities gets created, while Profile_rights and Profile_profile not. How to use them then?

In doctrine, join tables are not represented by an Entity.

You can find a @ORM\ManyToMany in your entities, with a @ORM\JoinTable and all informations about your associations.
This is the representation of your join table(s), use getters and setters like said by @Richard to access them.

Get more informations in the Associations mapping (to see all kind of associations) and Working with associations (to learn how work with them) chapters of the documentation.

Hope you have a good experience with doctrine.

EDIT

After look more at your UML, at least one of your associations doesn't need a many-to-many (As said by the first answer), but if they really have join tables in SQL, and you imported them by reverse engineering, they will surely be exactly as they are in SQL (a many-to-many with join table).

If you want to access the joining entity on a ManyToMany relationship you need to break it down to a OneToMany, ManyToOne.

E.g.

Profile - OneToMany < ProfileRight > ManyToOne - Profile.

Whether you should is another question. You only need to do this if you want to store extra data on the join table.

With what you have there it's trivial to get rights for a profile. For any profile you have loaded you simply call

 $profile->getRights() 

and doctrine will (assuming your generated entity mappings are correct) transparently fetch all the associated Rights entities for you based on the join table.

Similarly if you add a Right to a profile:

$right = new Right();
$profile->addRight($right);

Doctrine will transparently add the join table entry for you.