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

  • Home
  • SEARCH
  • 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 8395833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:23:53+00:00 2026-06-09T20:23:53+00:00

To delete a game Session from a web service we have defined the following

  • 0

To delete a game Session from a web service we have defined the following controller.

I expect one Session entity to be deleted, instead all records get deleted from the database.

SessionController.php

/**
 * @Route("/{id}/")
 * @Method({"DELETE"})
 */
public function deleteAction($id)
{
    $repository = $this->getSessionRepository();
    $session = $repository->find($id);

    $em = $this->getEntityManager();
    $em->remove($session);
    $em->flush();

    return new Response('', 200);
}

The services.yml contains:

  sh.repository.session:
    class: ScavengerWebserviceBundle\Entity\SessionRepository
    factory_service: doctrine.orm.default_entity_manager
    factory_method: getRepository
    arguments:
      - 'ScavengerWebserviceBundle:Session'
/**
 * @return \Scavenger\WebserviceBundle\Entity\SessionRepository
 */
private function getSessionRepository()
{
    return $this->container->get('sh.repository.session');
}

The entity contains:

<?php

namespace Scavenger\WebserviceBundle\Entity;

use Scavenger\WebserviceBundle\Entity\Battlezone;

use Doctrine\ORM\Mapping as ORM;
use \Doctrine\ORM\Mapping\OneToOne;
use \Doctrine\ORM\Mapping\ManyToMany;
use \Doctrine\ORM\Mapping\JoinTable;
use \Doctrine\ORM\Mapping\JoinColumn;

/**
 * Scavenger\WebserviceBundle\Entity\Session
 *
 * @ORM\Table()
 * @ORM\Entity(repositoryClass="Scavenger\WebserviceBundle\Entity\SessionRepository")
 */
class Session
{

    const SESSION_ACTIVE = 0; //lol

    /**
     * @var integer $id
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string $name
     *
     * @ORM\Column(name="name", type="string", length=255)
     */
    private $name;

    /**
     * @var integer $mrX
     *
     * @ORM\Column(name="mrX", type="integer")
     */
    private $mrX;


     /**
     * @var integer $causer
     *
     * @ORM\Column(name="causer", type="integer")
     */
    private $causer = 0;


    /**
     * @var integer $statusCode
     *
     * @ORM\Column(name="status_code", type="integer", nullable=false)
     */
    private $statusCode = self::SESSION_ACTIVE;


    /**
     * @ManyToMany(targetEntity="Scavenger\WebserviceBundle\Entity\User", mappedBy="sessions", cascade={"all"})
     */
    private $users;

    /**
     * @OneToOne(targetEntity="Scavenger\WebserviceBundle\Entity\Battlezone", cascade={"all"})
     * @JoinColumn(name="battlezone_id", referencedColumnName="id")
     */
    private $battlezone;

    /**
     * @var integer
     * @ORM\Column(name="start", type="integer") 
     */
    private $start = 0;

    /**
     * @var integer
     * @ORM\Column(name="end", type="integer")
     */
    private $end = 0;


    //a bunch of setters and getters ...
}
  • 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-06-09T20:23:55+00:00Added an answer on June 9, 2026 at 8:23 pm

    It’s because you’ve set “cascade=all” on $users field. I guess you have also the same cascade on “sessions” field in User entity, therefore if you remove some session object, all users related with that object will be removed as well AND all session objects related to these users will be removed too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making an android game that should delete some falling images from the
I'm trying to delete all data related to a user id from a game
Ok i am inches away from finishing this game, but I am getting one
I have a Flex 4.6 web game which displays 2 Lists with virtual layouts
Well i have some trouble removing an object from the game, the thing is
delete from a A where a.ID = 132. The table A contains around 5000
I delete my java program from java project in eclipse. The extension was .java
I need to delete rows in a table, such as DELETE FROM TABLE_X WHERE
how to delete/remove call log from application. I am doing like this this.getContentResolver().delete(CallLog.Calls.CONTENT_URI,null,null); it
We have a game project designed on ASP&SQL Server, and we need to integrate

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.