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 7853571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:44:20+00:00 2026-06-02T19:44:20+00:00

I am not able to authenticate in symfony2 with the ‘Employee’ entity as it

  • 0

I am not able to authenticate in symfony2 with the ‘Employee’ entity as it contains many mapping with other entities in my project. some of my mapping is as follows:

/**
 * @var EmployeeDesignation
 *
 * @ORM\ManyToOne(targetEntity="EmployeeDesignation")
 * @ORM\JoinColumns({
 *   @ORM\JoinColumn(name="employee_designation_id", referencedColumnName="id")
 * })
 */
private $employeeDesignation;

/**
 * @var EmployeeDesignation
 *
 * @ORM\ManyToOne(targetEntity="EmployeeType")
 * @ORM\JoinColumns({
 *   @ORM\JoinColumn(name="employee_type_id", referencedColumnName="id")
 * })
 */
private $employeeType;

Authentication works fine without any mapping. I have tried with ‘Serialize()’ and ‘Unserialize()’ methods in it like below:

class Employee implements AdvancedUserInterface, \Serializable {
    /**
     * serialize the username
     * @return serialize
     */
    public function serialize() {
        return serialize($this->emailOfficial);
    }

    /**
     * unserialize
     * @param $data
     */
    public function unserialize($data) {
        $this->em = unserialize($data);
    }
}

I am getting the following error after doing the above method:

You cannot refresh a user from the EntityUserProvider that does not contain an identifier. The user object has to be serialized with its own identifier mapped by Doctrine. 

I have tried this way so as to get rid of the previous error, which is as follows:

Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken::serialize() must return a string or NULL 

So, can anybody please suggest a way to overcome from this problem?

  • 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-02T19:44:21+00:00Added an answer on June 2, 2026 at 7:44 pm

    I have encountered something similar, and after some research, I tried the same things as you did.

    But at some point, I found out that by setting the __sleep method, every thing worked fine.

    class User implements PlayerInterface
    {
        /**
         * @var integer $id
         *
         * @ORM\Column(name="id", type="integer")
         * @ORM\Id
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        private $id;
    ...
    
        public function __sleep()
        {
            return array('id');
        }
    ...
    
    • Make sure that the field which is defined as @ORM\Id is part of the returned array.
    • Make sure to drop the browser cookie, since it uses the session.

    I don’t know exactly why it causes this when setting up a new association (mine was a ManyToMany), but It probably originate from this place:

    // see Symfony\Component\Security\Http\Firewall\ContextListener::onKernelResponse()
    ...
            $event->getRequest()
                ->getSession()
                ->set('_security_'.$this->contextKey, serialize($token));
    ...
    

    Hope this could help someone.

    Edit:

    References:

    • http://forum.symfony-project.org/viewtopic.php?f=23&t=35764
    • http://translate.google.com/translate?hl=en&sl=es&u=http://jonsegador.com/2012/03/error-con-symfony2-you-cannot-refresh-a-user-from-the-entityuserprovider-that-does-not-contain-an-identifier/
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am not able to deploy any project to Google App Engine and this
I want to be able to authenticate a WCF Rest webservice but I'm not
I've been able to finally get python-openid to authenticate a user, but I'm not
Not able to download artifacts from central maven repository. <mirrors> <!-- mirror | Specifies
Not able to store all binary data values into sqlite3 table using QT. For
not able to get this, can someone help for this LINQ query? select col1,
Im not able to load the page with circlepageindicator. This is the xml <FrameLayout
I am not able to apply onclick event in global custom text field. This
I am not able to build my application via Ant build.xml file when I
I am not able to start my app in emulator. Following is the message

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.