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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:39:46+00:00 2026-05-27T02:39:46+00:00

I have Doctrine 2.1 entity: /** * @Entity(repositoryClass=Varlab\Model\Repository\UserRepository) * @Table(name=user) */ class User {

  • 0

I have Doctrine 2.1 entity:

/**
 * @Entity(repositoryClass="Varlab\Model\Repository\UserRepository")
 * @Table(name="user")
 */
class User 
{
/**
 * @Id @Column(name="id",type="integer")
 * @GeneratedValue(strategy="AUTO")
 * 
 * @var integer 
 */
protected $_id;

/**
 * @Column(name="username",type="string",nullable=false,length=50,unique=true)
 * @var string 
 */
protected $_username;

/**
 * User password
 * 
 * @Column(name="passwd",type="string",nullable=false,length=50)
 * @var string 
 */
protected $_password;

/**
 * @ManyToOne(targetEntity="Role")
 * @JoinColumn(name="role_id", referencedColumnName="id")
 * 
 * @var Role 
 */
protected $_role;

/**
 * @ManyToOne(targetEntity="UserStatus")
 * @JoinColumn(name="status_id", referencedColumnName="id")
 * 
 * @var UserStatus 
 */
protected $_status;

/**
 * @Column(name="address",type="string",nullable=false,length=100)
 * @var string
 */
protected $_address;

/**
 * @Column(name="description",type="text",nullable=true)
 * @var string
 */
protected $_description;

/**
 * @Column(name="firstname",type="string",nullable=false,length=50)
 * @var string
 */
protected $_firstname;

/**
 * @Column(name="lastname",type="string",nullable=false,length=50)
 * @var string
 */
protected $_lastname;

/**
 * @Column(name="patronymic",type="string",nullable=false,length=50)
 * @var string
 */
protected $_patronymic;

/**
 * @Column(name="phone",type="string",nullable=false,length=20)
 * @var string
 */
protected $_phone;

// ... some get/set methods here

}

I try to update user entity using this code:

$item = $em->find('User', 1);
$item->setFirstname('some name');
$em->merge($item);
$em->flush();

But nothing is happened with firstname field in database. I look at Doctrine SQL log and see that doctrine does not fetch all fields:

SELECT t0.id AS id1, t0.username AS username2, t0.passwd AS passwd3, t0.role_id AS role_id4, t0.status_id AS status_id5 FROM user t0 WHERE t0.id = ?

If i try to change username, it is all right and field is changed in database.

$item = $em->find('User', 1);
$item->setUsername('some user');
$em->merge($item);
$em->flush();

Update SQL from Doctrine log:

UPDATE user SET username = ? WHERE id = ?

How can I fetch all fields of my entity? Why is it so?

  • 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-27T02:39:46+00:00Added an answer on May 27, 2026 at 2:39 am

    Doctrine 2 fetches all fields by default.

    Most likely the issue is one of the following:

    • I’m not sure if merge is the correct function to use. I’m pretty sure it’s persist
    • Your proxies might not be up to date. Check them.
    • Your entity metadata might not be up to date. If you cache your metadata, clear the cache and try again.
    • There’s an error in some of your mappings. Run orm:validate-schema from the command line tool
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two classes: User : /** @Entity @Table(name=users) */ class User { /**
I have entity for Doctrine: <?php /** * @Entity * @Table(name=orders) */ class Orders
Ok, I have a User entity as follows <?php class User { /** *
Entities in symfony 2 have doctrine tags that are preceded with @ORM\ (eg @ORM\Entity).
I have a service in which I inject the entity manager service (@doctrine.orm.entity_manager) because
I'm new in symfony2.I created a repository class when I created an entity class
I have a quite simple doctrine entity that represent a news ; this news
I'm struggling with the following, in a entity class I have a preUpdate lifeCycleCallback
I have an Entity that looks like this: class Privilege { /** * @Id
Using Doctrine 2. I have an entity called 'size' and I'm trying to form

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.