Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7008979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:48:16+00:00 2026-05-27T21:48:16+00:00

I have a join-table which is created by using @ORM\ManyToMany annotation in Symfony2/Doctrine. It

  • 0

I have a join-table which is created by using @ORM\ManyToMany annotation in Symfony2/Doctrine.
It joins Category and Parameter table.

Now I want to delete all parameters from the Parameter table. Because there are foreign key constraints defined on join-table I can’t just delete rows from Parameter table. First I have to delete child rows from join-table. But Dotrine’s DQL syntax require to give a name of the entity, like:

DELETE Project\Entity\EntityName

But what is the name of the join-table entity generated by using ManyToMany association? How to deal with it?

Alternately, how can I set ON UPDATE CASCADE and ON DELETE CASCADE on foreign key constraints in join-table defined by @ORM\ManyToMany annotation.

EDIT:

join-table schema:

CREATE TABLE `categories_params` (
    `category_id` INT(11) NOT NULL,
    `param_id` INT(11) NOT NULL,
    PRIMARY KEY (`category_id`, `param_id`),
    INDEX `IDX_87A730CB12469DE2` (`category_id`),
    INDEX `IDX_87A730CB5647C863` (`param_id`),
    CONSTRAINT `categories_params_ibfk_1` FOREIGN KEY (`category_id`) REFERENCES `allegro_category` (`id`),
    CONSTRAINT `categories_params_ibfk_2` FOREIGN KEY (`param_id`) REFERENCES `category_param` (`id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;

on UPDATE and on DELETE by default are set to RESTRICT

THE FINAL SOLUTION WOULD BE:

 * @ORM\ManyToMany(targetEntity="CategoryParam", cascade={"persist","remove"})
 * @ORM\JoinTable(name="categories_params",
 *      joinColumns={@ORM\JoinColumn(name="category_id", referencedColumnName="id", onDelete="CASCADE")},
 *      inverseJoinColumns={@ORM\JoinColumn(name="param_id", referencedColumnName="id", onDelete="CASCADE")}) 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:48:17+00:00Added an answer on May 27, 2026 at 9:48 pm

    To set cascade on doctrine level:

    @ORM\ManyToMany(targetEntity="Target", inversedBy="inverse", cascade={"remove", "persist"})
    

    More info: Doctrine2 Annotation Reference.

    To set cascade on mysql level:

    @ORM\JoinColumn(onDelete="CASCADE", onUpdate="CASCADE")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a join which deletes rows that match another table but the joining
I have two tables which I want to join together using a left outer
I have a MySQL Left Join problem. I have three tables which I'm trying
I have a join in a oracle query which looks like: FROM eiv.table1 eiv.table2
I have a primary table for Articles that is linked by a join table
I have the same problem as described in ( Last record of Join table
I have a query where I join a table on itself to find mismatches
I have a Movies and a Actors table and Casts as join-model. To be
I have a table with more than 100 columns. I need to join it
I have 3 tables I need to join. The contracts table is the main

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.